1,426 Posted Topics
Re: It will depend if it the list is single or double link. for single linked list if the list has a size member than you can create an array of type node and then go through the list and start filling the array from the end. Once you reach the … | |
Re: If ent is a single pointer to a CBaseEntity then you can do [code=c++] ent->frunction(); [/code] If ent is an array of CBaseEntity objects then you can do [code=c++] ent[i]->function(); [/code] If you are acessing a members of the CBaseEntity object and calling a function that exist for that member … | |
Re: Line 134 should be [icode]return str[/icode]. Line 29 should be [icode]bool isLeapYear();[/icode]. That should help you a little bit. | |
![]() | Re: How are you creating the project and what steps are you doing to debug and run the program? ![]() |
Re: this might be a little late in the game but you could always use a vector and have the vector defined as [icode]vector<vehicle*>[/icode]. with that you could add a car or a motorcycle to that vector. then when you want to remove a car or motorcycle you could do this … | |
Re: Here is a general purpose set up that should work for you. [code=c++] int rows, cols; // get rows and cols from user int ** array2d; array2d = new int*[rows]; for (int i = 0; i < rows; i++) array2d[i] = new int[cols]; [/code] | |
Re: in the code you posted above you add 3 values to que1 but you only remove 2 values from it so it shouldn't be empty. to be more specific lines 6 and 7 are for que1 but line 8 is just que | |
Re: Another apporach would be to use getline. Something like this should work [code=c++] string filename; cout << "Enter the filename: "; getline(cin, filename); ifstream OpenFile(filename.c_str()); //... [/code] You will need to add [icode]#include<string>[/icode] to your code for this to work. Also you are using the headers you have are depreacted. … | |
Re: using getline should work for you. I would suggest this [code=c++] // inside function string serial; cout << "Please enter a serial number. Enter to quit: "; getline(cin, serial); while(!serial.empty()) { serialNumbers.insert(serial); cout << "Please enter a serial number. Enter to quit: "; getline(cin, serial); } [/code] It is to … | |
Re: Maybe you could create a program that will compile the cpp files and save the assembly code into a file and then see if the assembly code is the same. Otherwise I guess you would have to create a parser and store the code as tokens and then match the … | |
| |
Re: to test for a newline i do [code=c++] if (word != '\0') myVec.push_back(word); [/code] | |
Re: As your example shows you have a number followed by a bunch of data. You could use a map the is defined as [icode] map<int, vector<something> > [/icode]. this would allow the number in each line to be the key and then the vector would hold all of the other … | |
Re: there is a random shuffle function in the algorithm header that might work for you. not sure if it can be used on 2d arrays though. | |
Re: you have a semicolon after your function name [code=c++] void average (int sc1, int sc2, int sc3,int sc4,int sc5); <--- get rid of this { // ... } void findLowest (int sc1, int sc2, int sc3, int sc4, int sc5); <--- get rid of this { // ... } [/code] | |
Re: Lines 50 and 51 in your orginal post do not have a return statement in them. | |
Re: have you tried to use the new and delete function instead of C functions? [code=c++] float * velx = new float[size]; // later on delete [] velx; velx = 0; //or velx = NULL; [/code] | |
Re: personally I'm not a big fan. I don't like all of the empty space at the bottom of a post. It makes it take up to much space. Just when I get used to the old interface they change it on me again. BTW is there a post that explains … | |
Re: there is a problem with your search user function. you never initialize i. your call to cin replaces the account number with whatever the user enters. to search for a record you need a for loop to check the number entered by the user against the numbers stored in the … | |
Re: What compiler are you using? fstream.h and iostream.h are big no no's. It should be [code=c++] #include <iostream> #include <fstream> [/code] Also I'm not seeing a [icode] using namespace std; [/icode]. Does this actually compile? | |
Re: you are not actualy defining string B. to define it to be be you could do this [code=c++] string B = "B"; [/code] | |
Re: I'm not seeing median declared in your main function at all. also the median is average value of all the values in the array. to calculate that you need to loop through the array and add all the values together. After that you then dived that sum by the number … | |
Re: well you need to use fstreams. Namely a ofstream. you can create a ofstream like this [code=c++] ofstream fout("experiment.dat"); // then use fout like cout fout << name << title << whatever; [/code] the file streams have the same functions and work the same as the console and keybord streams. … | |
![]() | Re: have you though about using the STL instead of arrays of pointers. I would suggest a list if you are going to be adding or deleting elements anywhere in the list or a vector if you are only going to be adding or removing elements from the end. from the … ![]() |
Re: I have to agree that the post are to wide now. I have to shrink my browser in order to get a window where I don't have to turn my head to see the whole line. BTW my res is 1280 x 1024 on a 19" monitor | |
Re: This is a link to Narue's sticky on posting questions [url]http://www.daniweb.com/forums/thread78223.html[/url] As far as I'm concerned this should be read by everyone who joins before the start posting. | |
Re: On a side not you should never use the increment operator on a number that hasn't been initialized. line 2 should be [icode] int number = 0; [/icode] | |
Re: to pass a string as a char * to a function if that string is in a vector you would do [code=c++] Foo(client_message[i].c_str()); [/code] | |
Re: please re-post this code with code tags and proper indentation. | |
Re: well you need to move your bid class above your simulator class to fix the second error because you are trying to use it before you have defined it. for the first error try using [code=c++] list.push_back ( this->getBids() ); [/code] | |
Re: to delete a pointer and know that it will never be a problem do [code=c++] Foo* p = new Foo; // later on delete p; p = 0; // since p is zero calling delete again will be safe [/code] | |
Re: You have i and j initialized to size so you are actually pointing to one passed the end of the vector. Replace [code=c++] int i=(int)ask.size(); int j=(int)buy.size(); [/code] with [code=c++] int i=(int)ask.size() - 1; int j=(int)buy.size() - 1; [/code] Also with this line [code=++] matchedAsk.insert(matchedAsk.end(),ask.end(), ask.end()+1); [/code] I belive you … | |
Re: I'm feeling helpful so I'll show you one way to do this. [code=c++] int counter = 1, x,y, zeroX, zeroY; int map[10][10]; srand((unsigned)time(0)); zeroX = rand() % 10; // this gets the spot to put the zero zeroY = rand() % 10; // place zero map[zeroX][zeroY] = 0; while (counter … | |
Re: well I'm not seeing a getName() function that returns an int so I'm clueless. | |
Re: Sounds like you might need to re flash your bios. | |
Hey All Yesterday I was writing a recursive form of a prime factorization program and I wasn't sure about the syntax I used. the function works as is but I'm curious if I am being redundant or if this is the proper way to code it. Here is what I … | |
Re: is Color part of [icode]using namespace System::Drawing;[/icode]? if not you need to include it in your point class. this is all i can get from this. | |
Re: on line 6 you are doing subtraction not addition. is that a typo or is this happening in you subtraction function? | |
Re: this is because of line 17. you are setting a pointer equal to another pointer so whatever happens to temp will also happen to b. if you want only the data in b to be the same as temp but not actually point to the same object you would have … | |
Re: I would look up prime factorization. That should point you in the right direction. | |
Re: as caut_baia stated you are returning a pointer but your function is defined to return just an object change this [code=c++] return rslt; [/code] to this [code=c++] return *rslt; [/code] | |
Re: the function is constantly reducing the number untill it is less than 10. lets say the number is 100. the function would print 0 for the first time. then you check to see if it is greater than 10. since 100 is greater than 10 we will call the print … | |
Re: the problem is line 18. [code=c++] Bible::Bible(string nam, int chapt, int vers, string testa, string txt) [/code] you dont have anything defined for this function. it should be [code=c++] Bible::Bible(string nam, int chapt, int vers, string testa, string txt) { // stuff here } [/code] | |
Re: there are a bunch of post already about doing this. try this [url]http://www.daniweb.com/forums/search6116243.html[/url] | |
Re: well for starters the code you are using to populate the array with your o's and x's is not right. you are using a for loop but what would happen if the cords you get already have a o or an x? you would do nothing and then start the … | |
Re: shouldnt his char array be defined as something like [icode]char script[2][50][/icode] or do i have it backwards? | |
| |
Re: I think I have made a solution to this. How would you like to see my code. I didn't know if I should post it or let others have a chance. |
The End.