1,426 Posted Topics
Re: yes you need to declare first last and x inside your function in order to use them. what SasseMan was saying is you need to define the operator = for your class. it is a god idea to write your own because the default just dose a shadow copy of … | |
Re: I'm not seeing a main function anywhere. do you have this code in a main function? | |
Re: i would have sGuess be a char variable in this case. as stated earlier there may be multiple occurrences of the guess letter in the random word. for that reason you would either need another array to keep track of the positions in the random word or you could use … | |
Re: there is a function tolower that you can use to help you with this. | |
Re: the problem you are having is on line 19. when you declare a 2d array you declare the rows and columns of the array. your statement [icode] int PlayerInfo[MAX_PLAYERS][pInfo]; [/icode] is saying define an array of 32 rows and pInfo columns. since pInfo is a type and not a value … | |
Re: the problem is on line 70 and 76. on line 76 you have [icode] cout<<name.top()<<" "; [/icode]. here you are outputting the top object int the stack which is of type Lexeme. you either need to define and operator<<() function for your class or call an accessor like [icode] cout<<name.top().getLex()<<" … | |
Re: it looks like you are doing your checking of the guess in the blankspaces function. so if that is the case then i would add a line in you else statement of the [icode] if(flag) [/icode] statement to increment inCorrectGuess [code=c++] //... if (flag) { //... } else { cout … | |
Re: have you tried using vectors? you could store the separate strings in a vector just like an array and pass the vector into the function. also is your function did you want to take in an array of strings or a single string at a time. you only need one … | |
Re: could we see some code? its kinda hard to see you computer screen from here | |
Re: you need to move your declaration of y to be before the do statement on line 23. the reason is that when the compiler hits the while statement it hasn't seen the deceleration for y so it doesn't know what it is. also a easy way to do the while … | |
Re: well one good practice to get into is to set your pointer to null after you delete it [code=c++] int * a = new int[30]; delete [] a; a = NULL; //or a = 0; [/code] this will make sure the the pointer no longer points to where it used … | |
Re: also you have not terminated the array with a newline value so cout does not know where the end oh the char array is. | |
Re: i use 2 computers. one desktop and one laptop. to be fair though the desktop has 3 screens that i use :) | |
Re: a way you can do this would be to have a void check function inside a while loop in your main function. [code=c++] void CheckInput(char[80], bool*); int main() { char[80] cake; bool good = false; while (!good) { cout << "please enter a cake: " cin >> cake; CheckInput(cake, &good); … | |
Re: well with polymorphism you do need to use virtual functions in order for the program to know which functions to use. since it isn't virtual it is calling the horse operator=() function instead of the pony's operator=() function. there is a little more overhead with virtual function because of the … | |
Re: i assume you didn't read the second post on the page where it says we only give help on homework to those who show effort. do you have any code and having a problem with it? do you have any idea what the logic should be? variables? | |
Re: woot 7 right. and im a leader with a 64. not quite sure what the scale is out of though. | |
Re: well you being asked to provide the information in the constructor so you should have something like [code=c++] class DayOfYear { public: DayOfYear(int day) { day = y; } //... }; [/code] the you initilize the class like [code=c++] int main() { int day; cout << "enter the day: "; … | |
hi all. I'm not sure if its possible but can you call a different constructor inside a constructor of a object? ie can i have different constructors call a single constructor to set up the object [code=c++] class foo { public: foo(int) foo(double) //... }; foo::foo(int number) { this = … | |
Re: well i got it running. i deleted the [inlinecode] #include "stdafx.h" [/inlinecode] and changed [inlinecode] qu_main(argc, argv) [/inlinecode] to [inlinecode] int main() [/inlinecode] | |
Re: in your if statements in your maze traverse function you have [inlinecode] (x+1, y) != 'A' [/inlinecode]. im not quite sure what this is. did you mean to do [inlinecode] if (mouse[x+1][y] != 'A') [/inlinecode] also on line 38 you have [inlinecode] if (maze[x][y] == 'T') [/inlinecode] but there is … | |
Hi all. I am currently writing a large number class and was curious if I should use a template. I am setting up my constructors and I have one for a string and i was thinking i could use a template for a constructor so it can take in an … | |
Re: whet testing single chars you need to use the single quote such as [code=c++] if (op == '+') // this is okay if (op == +) // this is not okay [/code] also when you are testing conditions you are using a single =. testing equality in c++ is done … | |
Re: i noticed on line 17 you a creating a new SYM object. have you tried using the new keyword? [code=c++] SYM * temp = new SYM[N]; // using the size you passed into the function for the array [/code] | |
Re: also line 30 should be [inlinecode] size = arraysize [/inlinecode] not the other way around. | |
Re: you really don't need to declare the size of the string when you create it. it is good practice to do so but the string will automatically re size itself when it needs to do so. this will make a little performance hit though. | |
Re: that is the problem [code=c++] cout << 'a'; // good cout << ' '; // good cout << 'ab'; // bad cout << ' '; // bad [/code] | |
Re: you can have the input statement inside the loop [code=c++] int accnum; int accountnum[1000]; for (int i = 0; i < 100; i++) { cout << "please enter an account number: "; cin >> accnum accountnum[i] = accnum; } [/code] | |
Re: the problem with the line of code you are using is that it is calling multiple functions. when the program runs it will take the return of the function and instead of keeping it in the registry it will put it into the ram which will truncate the number and … | |
Re: also you are starting the variable heads at one which will throw off you answer. you should initialize both heads and tails as 0. | |
Re: where are you setting the emp in the node. i see this block for file input [code=c++] while (fin >> number) { head = new LISTNODE(emp , head); } [/code] but with this you are not doing anything. first you need pull the information into your employee struct and then … | |
Re: wehat error arer you getting. also when you define a template you would normaly use the syntax [code=c++] template <typename T, typename C> class Template { //... }; [/code] | |
Re: well if your complier is compiling project01.cpp be for your main.cpp file then it doesn't know what MAX_COLS is yet. try moving the declaration into the project01.cpp file and see what happens | |
Re: well you could use the stl such as a vector or list or if your not allowed to do so you could copy the array into a new array skipping the one you want deleted and then delete the original array then return the new array. | |
Re: also in the first program there is no memory leak. | |
Re: i found this site and it has g++ for Linux [url]http://gcc.gnu.org/wiki/GFortranBinaries[/url] | |
Re: you cant have an undefined amount of variables in function deceleration. you must declare what the function returns and all parameters the function takes. if you want to send a few or alot of one type of thing i would try using an array of some sort like [code=c++] void … | |
Re: sorry but your post doesnt make sense. if we use 2/5 - 1/2 with your formula we get: numerator = (2 * 2) - (1 * 5) = 4 - 5 = -1 denominator = (2 * 5) = 10 so your fraction should be -1/10. not sure why you … | |
Re: so your not sure how to get the abs_minimum? arent you calculating it in you next function [code=c++] if (count <= 0) { count = 1; total = r; tinyest = r; largest = r; return; } count = count + 1; total +=r; if (r < tinyest) { tinyest … | |
Re: could you please post your code | |
Re: well if you want to check for a " in a string then you can write. [code=c++] if (somestring[n] == ' " ') // i put a space between the single quotes and the double quote so you could see it. in your program just put '"'. { //... [/code] | |
Re: i had a similar problem writing a string to a file and i got some good advice. [url]http://www.daniweb.com/forums/thread203217.html[/url] | |
Re: i think there is a win API function to see what programs are running but i cant remember. have you thought about multithreading instead? | |
Re: at what line in your code the the assertion happen? also is the value for Ypix what you see when the debugger gets to that line? if show it is showing you the value of Ypix before it is assigned to 0. | |
Re: well when i add you number together and i dived by 5 I'm getting 8.004. so with your round function you would have ((8.004 * 100) +.5) / 100 = (8.4 + .5) / 100 = 8.9 / 100 = 8.009. with the floor of 8.009 being 8. I'm not … | |
Re: have you tried making your output stream a fstream like your input stream and using the write() function? | |
Re: my advice would be to add a member variable to the patient class of type doctor that you assign when you get a doctor. this way you could call the member doctors get fee function. [code=c++] class Patient { public: // ... void SetDoctor(Doctor & doc) { doctor = doc; … | |
Re: as ancient dragon said you need 2 char[]'s. one for the fully assembled file name and one for the user supplied file name. [code=c++] char filename[30]; // used for the total filename char FileName[20]; // used to get the filename from the user int a,b,c; cout << "please enter the … |
The End.