429 Posted Topics
Re: I don't know of any tools but it seems from the error that it cannot find the definition of some function called NodeFactory::CreateNode . Can you think of any reason why that could be? | |
Re: [code=c++] #include <cmath> #include <iostream> using namespace std; int main() { int num, countA, countB; cout << "Please enter a positive maxiumum integer value you wish to find divisors: \n"; cin >> num; if (num <= 0) { cout << "The input entered was invalid. Please input a positive whole … | |
Re: cin leaves the newline character in the stream, which gets consumed by cin.get() and it doesn't help. put a cin.ignore after the last cin and then cin.get() as pointed above. For a more thorough explanation check this [URL="http://www.daniweb.com/forums/thread90228.html"]http://www.daniweb.com/forums/thread90228.html[/URL] | |
Re: If you mean something like the Java 'Object' class which is the superclass for everything, then no, C++ doesn't provide it per se, but you can always implement it by having a common base class which every class inherits and which has the properties of being a superclass to every … | |
Hi, We have created an ER diagram for the below mentioned scenario. This is the first time we're doing this, some comments would be useful Problem statement: A website which allows students to sign-in and register for different courses. Students can then create question sets for registered courses. Each question … | |
Re: Have you seen the reference on assert function? It says that it needs an expression, and if the value of the expression is '0' , it terminates the program. Now since what you have is just 2 ints that represent the day and the month, it is upto you to … | |
Re: For strcat to work the destination should be large enough to hold the concatenated output. temp points to a memory location that is big enough to hold the filename and nothing more. | |
Re: You can find a lot of material on coding up BFS on the net. What language are you going to code it in? If you have tried something, post in the relevant forum and you would get a lot more specific help. And try to explain it better. | |
Re: You ought to know at compile time if a class is updatable or not, because they will derive from the IUpdatable. So just add a field in Object class, isUpdatable, and set it appropriately for classes that derive from IUpdatable and classes that don't. | |
Re: [Quote] 1. Array Totaler: Given an integer array of size 50 (Filled with numbers read in from a file called “numbers.txt”, which is assumed to have 50 integer values), do the following: A) display the array to the screen (use 5 rows of 10 numbers each), B) ask the user … | |
Re: [QUOTE=suncica2222;1121242]I use MS VC++6 and when I type code I have problem...let's say I have 123456789 typed and I place cursor between 4 and 5 and than type "something" I get 1234something and not 1234something56789 so it deletes and wont shift right :S also enter doesnt brake new line,space,backspace.... I … | |
Re: [QUOTE=28daniela28;1110706]I have the following code ( I'm creating a binary tree and then I want to print the values on it's leafs) but when I'm running it, it never enters in that if from the parcurgere function. What have I done wrong? [CODE] void creare(node *p) { //your code } … | |
Re: Yes you can do that, for example [code=c++] class A { public: int func() { return 1;}; }; class B { public: A a; }; int main() { B b; b.a.func(); } [/code] | |
Re: I know i shouldn't be stretching it more but this is funny .. I'm sure the OP would have become quite a programmer by now... prince of persia :) ... | |
Re: Another approach could be: 1. Read in a number as a string 2. Take one character from the front, convert it into a number and push it in a stack - Stack-1 3. Keep doing step 2 till you've pushed the entire string on the stack with the least significant … | |
Re: [QUOTE=ppotter3;1112886] [CODE] void SearchNames(string names[], int &rTotal, string &rNameONE, string &rNameTWO, int &rCount_NameONE, int &rCount_NameTWO, bool result_NameONE, bool result_NameTWO) { /* This is the search function that implements a basic brut force search to find the specified names that the user inputs. */ rCount_NameONE = 0; rCount_NameTWO = 0; result_NameONE … | |
Re: [QUOTE=cerr;1113445]Hey all! I have this assignment for my school project to create a simple address book using classes that do the routine stuff like adding a contact, searching it, modifying it, deleting it... Here is the code but it won't run properly. I tried but couldn't figure it out. It'd … | |
Re: [QUOTE=wot;1113585]Hey guys, I'm new to C and I am trying to find a way to create a file with the following array: [/QUOTE] And if you are trying to learn C, you'd be better off posting questions in the C forum or you might get a little mixed up. | |
Re: You've passed the function pointer but where are you using it? | |
Re: [QUOTE=webdragon89;1113220]I have n!/((n-r)!r!) which I figured out how to make recursive: [CODE]int crn (int n, int r) { if (r==0||r==n) return 1; return (n-1)+(n-1,r-1); }[/CODE] how do I make it non-recursive?[/QUOTE] what is this?? This is not a program, nor is it a recursive function and it does not calculate … | |
Re: [QUOTE=sidra 100;1111808] Two constructors: A default constructor: A constructor that initializes the attribute ms where ms is the maxSpeed. An overloaded constructor: A constructor that takes ms as an argument, where ms is the maxSpeed.· [/quote] 1-> You have not defined the overloaded constructor body. 2-> Are you sure you … | |
Re: Either define the cCourselist ctor or remove it's declaration from the class body so that the compiler is able to define one for the class | |
Re: These are the 2 overloaded declarations of erase in vector: [code] iterator erase( iterator loc ); iterator erase( iterator start, iterator end ); [/code] Both of them take an iterator as argument and not int | |
Re: We do not do other people's assignment. If you try to do it on your own and get stuck then you can post the code here and ask specific questions about the problems you are facing. That's the way it works. | |
Re: I don't thing it is overly complicated, seems neat to me. You could divide the class declaration and function definitions in different files, .h and .cpp and main could be in another 3rd file which includes graph.h and just uses whatever it wants to. You can define the structs edges … | |
Re: in case you are wondering, why you haven't got any useful replies, let me tell you. The question is vague, you have not provided any main function so we don't know which functions you want to call, how is your input stored and why you are not able to pass … | |
[code=c++] int main() { int i=10; char arr[i]; } [/code] I was expecting an error but it is compiling without any issues. I'm assuming the g++ compiler is doing something but not sure how to disable that. This is my compiler info [quote] Using built-in specs. Target: i486-linux-gnu Configured with: … | |
Re: A very quick answer: You will have to use dynamic arrays [code=c++] int* arr = new int[word.length]; [/code] | |
Re: You are using pass-by-value semantics for passing method parameters as a result the changes you make, to the object, inside the functions have not effect on the actual object. Pass the parameters by reference and try. | |
Re: and shouldn't this [code=c++]AdditionalWindows(*wxWindow parent); [/code] be [code=c++]AdditionalWindows(wxWindow* parent); [/code] ? | |
Re: [QUOTE=Jetsetivan;1104299] [CODE] int main() { // Request and obtain valid decimal numbers int A = obtaindec('A'); int B = obtaindec('B'); // Convert A and B to binary and store as vector<char> arrays vector<char> Abin = dectobinstring('A', A); vector<char> Bbin = dectobinstring('B', B); // Create C based on the largest size … | |
Re: [QUOTE=DavidDD;1103859] [CODE] void mainSPGameFunc() { readFileGetRandom(); string sSelectedWord = readFileGetRandom(); string sGuess; int iWordLength = sSelectedWord.length(); cout << "Guess the word!\n"; for(int i = 0; i < iWordLength; i++) { cout << "_ "; } cin >> sGuess; [B]for(int i = 0; i < iWordLength; i++) { if(sGuess == sSelectedWord[i]) … | |
Re: Well that's one big code you've posted there, nobody can help you on that quickly, unless you clearly mark out a piece of code that is not working correctly or state your problem in much simpler manner or just about anything that makes one focus on some part of the … | |
Re: Well the code is doing what it's supposed to do, but I don't understand this, why are you doing this on your 4th day of C++ ? If it's just a matter of this piece of code then may be it's ok but if this is how you are trying … | |
Re: [QUOTE=flying_bird;1097490] [code] template <typename T, typename LESS_THAN> void RestrictedSet::insert (const T elem) { _S.insert (elem); if (++_size > _max_size) drop_worst(); } [/code] The problem must be somewhere in the template part, I get the error: [icode] agenda.cpp:28: error: ‘template<class T> class RestrictedSet’ used without template parameters agenda.cpp:28: error: variable or … | |
Re: [QUOTE=jakesee;1096502]Hi, This is a very convoluted problem I spent hours debugging to find that when I call std::vector<object>::push_back(Object()) destructor of previous Object is called. Is this the behaviour of std::vectors or is something wrong with my code? [/QUOTE] It could be happening due to resizing of the vector. Once the … | |
Re: Since sm_fileData is static member, wherever you are defining it, at that point the default ctor of class QFile is getting called and sm_fileData is getting initialized. You cannot call another ctor on it at any later point of time. You can try using the QFile's open function (cross check … | |
Re: It is not clear from your post what exactly you wanted to do. Did you want a function pointer to a static class member function? That is not so difficult and in fact is same as non-class functions. However since the code you have posted does not contain any classes, … | |
Re: [code=c++] template <typename Type> void dbList<Type>::insertNode(Type v) { Node<Type>* tempa; Node<Type>* tempb; Node<Type>* tempc; tempa->data=v; if(this->head==0) { this ->head = tempa; this ->head ->next = 0; this ->head ->prev = 0; this ->size++; this ->head->position=size; } else { tempb = this ->head; if(tempb ->next == 0) { tempa->next = tempb->next; … | |
Re: It doesn't look like C++ code at all. And the moderators might prove that in sometime by moving it to the C forum !! | |
Re: [quote]InvalidArgumentException::InvalidArgumentException(class InvalidArgumentException const &)" (??0InvalidArgumentException@@AAE@ABV0@@Z)[/quote] I think the problem is that your copy ctor is declared but not defined and somewhere you are trying to make a copy of your class 'InvalidArgumentException' . [code=c++]InvalidArgumentException(const InvalidArgumentException&);[/code] so you could either provide a copy ctor definition or remove any copy attempts from … | |
Re: IMO you should create those objects separately and then add them to the vectors and sets of the factory class. Factory, in your case (and very misleadingly), looks like a collection of all other types and I don't think you should create these objects in the Factory, rather, just create … | |
Re: [code]Form1 ff = gcnew Form1();[/code] it probably want's you to declare 'ff as a 'Form1*', but i could be wrong since i've never seen the 'gcnew' operator before. | |
Re: [quote]I must be missing something, how do I properly return a 2-d string array from a function?[/quote] you could do something like [code=c++] typedef string (*StrArrPtr)[numCols]; StrArrPtr get_elements() { //Do your stuff, string arr[numrows][numcols] return arr; } [/code] words of caution: Make sure you are not returning address of a … | |
Re: [code=c++]string_in[j][i]!=un_lock[j][/code] un_lock is a string, and un_lock[j] is a 'char' at position 'j'. while string_in[j][j] is a string. hence the error. You are trying to compare a string with a char and the compiler tells you that it is not allowed. You're 2nd attempt just changes the error because you … | |
Re: [QUOTE=qwertymk;1085717]So basically this is all that is required? [CODE] ~live() { if (_next) delete _next; } [/CODE] for the destuctor?[/QUOTE] you don't need the 'if' either, if _next is NULL then delete will not create any problems. | |
[code=c++] class A: public B { C* p1; C* p2; } [/code] What would be a correct assignment operator for class A? We have to ensure that we do not leave any object in an inconsistent state due to any exceptions or create any dangling references or memory leaks. | |
Re: Why don't you use a 'vector' class instead of arrays? It would be much easier to use. | |
Re: [code=c++] while( (g.one != 'r') || (g.two != 'p') || (g.three != 'g') || (g.four != 'm')) [/code] that's how you give multiple values, you can modify it to suit your requirement | |
Re: [code=c++] //input/output functions //void read(); friend istream &operator>>(istream &str, Date&d) { char skip_char; str >> mn >> skip_char >> dy >> skip_char >> yr; } [/code] The compiler might be asking you to access 'mn' , 'dy' , 'yr' using the Date reference. something like [code=c++] str >> d.mn ... … |
The End.