1,426 Posted Topics
| |
Re: This is the line with your first error cout << "Congrats! Your score is: \n" << getline(cin, x.score) << endl; Right now you are trying to use getline to display a value which will not work. You are also getting the error about x not being declered here. x should … | |
Re: Well if you use `getline()` it will read in everything in the file until it reaches a newline. You can read about it [here](http://www.cplusplus.com/reference/string/getline/). | |
Re: The way you have your code now if either stream fails it will end the loop. The problem is you arent doing anything after that. I would do this a little differently. Look at how this works. while(getline(firstFile, line1) && getline(secondFile, line2)) { thirdFile<< line1 << endl << line2 << … | |
Re: Line 5 is wrong. you do the initialization of the varibles in the constructor. | |
Re: Your main function needs to be outside of your class defenition | |
Re: Well you could make a base class that has a generic function called `getList()` that would display the list. Then you could derive your differnt kinds of list from that base class. then the `foo()` function will get passed a pointer to the base class so it can except both … | |
![]() | Re: Why are lines 15-17 inside your constructor? Your close bracket on line 18 should be on line 15. ![]() |
Re: What kinda of file processing do you need to do? You might want to check [This](http://lmgtfy.com/?q=working+with+files+c%2B%2B) out. | |
Re: You are not reseting count anywhere. After line 16 put `count = 0;` and see what happenes. | |
Re: I think I'll stick with the use of `c_str()` for the time being. Ill wait till c++0x becomes more widespread. | |
Re: modify is a `char *` not a `string` therefore it does not have `rbegin()` or `rend()` member function. Do you have to work with a `char *` or can you use a `string`? If you have to use a `char *` then you need to know the legnth of the … | |
Re: I think the issue is comming from how you are sizing the vector. I think you should use this to define the size of the vector in your constructors. grid.resize(rows); for (int i = 0; i < rows; i++) { grid[i].resize(cols); } | |
Re: Are you trying to remove the .cpp file from your project? | |
Re: This was alread answered [here](http://www.daniweb.com/software-development/cpp/threads/386160/input-sorting-without-arrays-pointers-or-vectors#post1664744). It is a trick question. | |
Re: You say Heading is a QString. Why to you have the () after it? Is it a function that returns a QString? What happens if you do `QString = theArray[10].Heading()`? | |
Re: I think you need to change line 15 to if ( i < 4 && myArray[i] == myArray[i+1]) The way you have it now the last time you go through the loop you are going past the end of the array and it will cause undefined behavior. | |
Re: When you say it just stops does it lock up or does it display the value of b? | |
| |
Re: Have you checked output_file to see if it is opening the file. ou can put this in your code after you open the file to make sure it is really opening the file. if(output_file.fail()) cout << "The file could not be opened!\n"; | |
Re: Your loop should look like this for(int i=0; i < 50; i++) { infile >> list[i]; cout << list[num]; } You also dont need to put it in a while loop if you know you are only going to read 50 records. If you dont know how many records you … | |
Re: @AD strEmployeeCategor is an STL string not a char[]. I think the issue he is having is that he is trying to compare floats and he has one of those .00000000000001's hanging around. | |
Re: It is a default parameter. If you do not send anything then it will default to zero but if you pass a value it will get the value passed. To pass the value you would need to have a child constructor like this. Child(int n) : Parent(n) { cout << … | |
Re: well you need to use a loop and go from the next odd number greater than what you entered untill you find a number that is prime. bool prime = false; while(!prime) { // check if number is prime // if number is prime set prime to true // increment … | |
![]() | Re: currently you are doing nothing with the vector you have in your function. since it is a local variable of the function it gets created and destrroyed everytime you call the function. If you want to get all of the words from a text file into a vector you can … |
Re: To display the contents of an array you need to use a loop. | |
Re: Well you can see if the line from the user contains the words open and door. Something like this if(userInput.find("open") && userInput.find("door")) // open door You can also get a little more complicated and make sure you find open before the word door. | |
Re: So what is your problem? From what I can see you dont define count in your strlength function. As far as I can remeber strings from the string type are not terminated with a `'\0'`. You can you the `size()` function to find the legnth of the string. You would … | |
Re: The error you are getting is saying that it can’t find an operator << that will take a vector. The vector class does not have built in stream operators so if you want to pass a vector to << than you need to write your own function to do that. | |
Re: Line 8 needs to match the first par of your for loop. The codition of the while loop needs to match the condidtion of the while loop. The very last line of the while loop needs to match the last part of the for loop. In you case you need … | |
Re: You are using a long int which has a max value of 2,147,483,647 so if you give it 5,744,074,063 it is going to wrap around. you can try using a long long which is 64 bits with a max value of 9,223,372,036,854,775,807 | |
Re: You can right your own pow function like this int power(int base, int exponent) { int result = base; for (int i = 1; i < exponent; i++) { result *= base; } return result; } | |
Re: You need to pass the salary on line 195 to the SalariedEmployee constructor | |
Re: Well you need to write a sort fuinction that will take an int array and sort in asscending order. You will need to repet this for decimal types and char types. Then you have to write the same sort function but change them from asecending to decending order. This will … | |
Re: I believe line 11 should be `p = p->link` and you can get rid of lines 4,5 and 12. | |
Re: You can use a loop but you need to store your scores in an [array](http://www.cplusplus.com/doc/tutorial/arrays/) | |
Re: As you have with your first example you declared 2 Window pointers and made one a Window and one a CommandButton. In your second example you had to have a Window and a CommandButton pointer. So having virtuall functions allow you to cast a derived object to the base and … | |
Re: int * Foo() { int * returnValues = new int[what ever size array you want here] // do stuff return returnValues; } // in main int * getReturnValues = Foo(); | |
Re: I found [URL="http://podofo.sourceforge.net/about.html"]this[/URL] while googeling. Might be something worth looking into | |
Re: So what is the problem you are having? If you want to generate all numbers less than n that equall 2^k-1 than you can do this for(int k = 0; k < (int)pow((double)2,k) - 1; k++ { // check if (int)pow((double)2,k) - 1 is prime } | |
Re: When you say the outside numbers you mean the numbers that are going to be multiplied together like a standard multiplication table? | |
Re: First things first. when you want to check if more than one thing is equall to the same value you have to do if(x <= 100 && y <= 100 && z <= 100) Secondly you can only fave one return value in a function. You can not return three … | |
Re: In your system you could have a CR/LF for \n. This would mean you have two charecters to get rid of. An easy way to get arroung this is to take in everything as a string and then convert the string to get what you need. If you want to … | |
Re: You need to define the size of the 2d array. The way you have it now it should the compiler will make it 2X12 whn you actually need it to be 12X12. I would change it to `int prodouct[ROW_SIZE][COLUMN_SIZE];` | |
Re: We are not going to do your homework for you. If you have some code that you would like us to check post it. If all you are going to do is beg for code than you should realize that you are violating the member’s rules. | |
![]() | Re: Static functions are generally used when you have static data members in a class and you want to be able to acess the static data. You have to have a satic function to acess static data since it is seperate from the objects of that class. |
The End.