1,426 Posted Topics
Re: Well the main problem with starting the construction of a class from the derived part up to the base is that any variables you are using that are in your base in a function in your derived class would be undefined. Assume this situation. [code=c++] class A { int number; … | |
Hey all I have seen a lot of stuff about palindrome checkers so I thought I would write one that works for STL containers as well as arrays. it accepts a bidirectional iterator to the first element and an bidirectional iterator to 1 after the last element. Included is a … | |
Re: @ oieronle We are here to help people with there code not give them the code if they don't have any. Secondly if you are going to post code please use code tags. Third your loop wont work like you think it does. When i is 1 it gets decremented … | |
Re: I'm not exactly sure what you mean by adding or multiplying a file. Also what do mean by reducing the file by a few bytes. A AMD 2 GHZ processor single core will do about 3500 MIPS or 3500000000 instructions per second. A 2 GHZ processor will have 2 billion … | |
Re: First - declare a counter variable and set it to zero. Second - use a while loop with a getline call as your loop condition. Third - increment the counter variable. Fourth - see if the word you are looking for is in that line. Fifth - If it is … | |
| |
Re: The reason the first letter is missing is because you are calling ignore before you call getline. You still are passing 2 objects to your functions when you should only be passing one object. [code=c++] void MovieDisplay(MovieData m1) // instead of void MovieDisplay(MovieData m1, MovieData m2) [/code] | |
![]() | Re: yes there is a rule. types are promoted to a higher type if assigned to a higher type. going from a higher type to a lower type works as well but there can be truncation of the number [code=c++] int foo = 5; float bar = 3.5; float result = … ![]() |
![]() | Re: well if you want the user to be able to keep inputting a number for the change to be computed the you can wrap the whole thing in a while loop [code=c++] char ch = 'y'; while (ch == 'y' || ch == 'Y') { // lines 17-44 here cout … |
Re: Yes you can splice the line. They have some nice fittings that you don't even need to flare the end it will do it for you when you tighten the fitting. | |
Re: If you want to have really big numbers then you will need to use strings. if you dont need more then 12-15 digits than you do this [code=c++] #include <iostream> #include <string> #include <sstream> using namespace std; int main() { long double input; string number; cout << "Enter a number: … | |
Re: Well ASCII characters run from 0-255 so any number between 0 and 255 will convert right to an ASCII value [code=c++] int number = 48; char character = number; // character is now '0' [/code] Numbers larger than 255 should wrap around but you can always use the % operator … | |
Re: probably because the compiler is using the public method from your derived class. Secondly why are you using a void * ? Third new is used to create objects on the free store. the proper syntax would be [code=c++] int * number = new int; int * numberArray = new … | |
Hey All This code is for matching a string with a wildcard in it to another string. If you want to have a Astrix in the first string be counted as a character and not as a wildcard put a \ in front of it. I have tested it for … | |
Re: 1. Get a c/c++ compiler. IDE's are nice and some are free. 2. Write the code for the program you want to create. Make sure to follow go techniques. 3. Compile the program. 4. Use the program you just created. Follow these four easy steps and you will be on … | |
Re: So you need to create a queue for your time class? Do you have anything yet? | |
Re: I would suggest stepping through your code with the debugger to see where you are exceeding the memory allocation. | |
Re: I also came up with a verson of this. Not quite as nice as firstPersons but it does the job [code=c++] #include <iostream> #include <string> #include <vector> void Split(std::string word, std::vector<std::string> & pieces, const char * splitChar) { std::string::const_iterator it = word.begin(), end = word.end(); std::string temp; unsigned int counter … ![]() | |
Re: Does anyone know how popularity is computed? Is it forum dependent or is it weighted against all post in daniweb? I'm just curious because so far I cant see a pattern. | |
![]() | Re: You should avoid using .eof() as your while condition. I can't remember the post where they do a good job explaining it but you should be able to find it. for your while condition I would do [code=c++] while (recordFile.read((char*) &temp[i], sizeof (participant))) { //... } [/code] this will make … ![]() |
Re: Line 46 says fills array with hex but you are not actually doing that. Could be your problem | |
Re: Well if you have different variables you can do this [code=c++] int a,b,c; a = 1; b = 2; c = 3; a = b + c; b = a; // b is now a which is 5 [/code] | |
Re: well you can overload the operator= function for Point [code=c++] bool operator=(const Point & rhs, const Point & lhs) { return ((rhs.x == lhs.x) && (rhs.y == lhs.y) && (rhs.z == lhs.z)); } [/code] | |
Re: if you want to get numbers from a and put them in c then you can do this [code=c++] a >> x; c << x << endl; [/code] | |
Re: do you want to store different types of data in this container at the same time? [code=c++] Container stuff; int a = 5; char b = 'b'; double c = 3.14; stuff.add(&a); stuff.add(&b); stuff.add(&c); [/code] | |
Re: if else statements do not get warped in brackets like you have here. the way they should look is like this [code=c++] if (something) { // code here } else { // more code here } // and for nested statements if (something) { if (somethingelse) { // some code … | |
Re: in your sort function you should be able to do [code=c++] // ... while (x < maxSub) { if (properties_copy[x].price > properties_copy[x + 1].price) { temp = properties_copy[x]; properties_copy[x] = properties_copy[x + 1]; properties_copy[x + 1] = temp; //... } //... [/code] | |
Re: try this [code=c++] cin.ignore(80, '\n'); // instead of cin.ignore(); [/code] | |
Re: There are a bunch of different cases you will have to use to solve this. First I would separate the extension from the file name. Then for a simple case like "*.txt" you would just use the extension string to match the file names. [code=c++] std::vector<string> wordList; std::vector<string> matches; // … | |
Re: You could define it like [icode]int* spaces[3];[/icode] | |
Re: You could have a newline in the input buffer that is getting extracted by the call to getline. That would give you an empty string. Try doing this. [code=c++] //... cin.ignore(80, '\n'); cout << "Enter serial number to be removed. Enter to quit:"; getline(cin, serial); [/code] | |
Re: What have you tried so far? | |
Re: Because there is a newline left in the buffer from the call to [icode]cin >> gender[/icode]. You will need to get it out before you call getline again. Narue has a good post about there [URL="http://www.daniweb.com/forums/thread90228.html"]here[/URL] | |
Re: First void main is not standard. main should only return an int as per the ISO standard. Secondly all of your header files are deprecated. What compiler are you using? You might also want to change where you compare the user answer to the answer in the file. I would … | |
Re: Change your do...while loop to a while loop and use k as your tracker for your exit condition. [code=c++] while( k != myToken.size()) { char s = myToken[k]; // no ++ here // rest of your code here k++ } [/code] The reason for this is that you are running … | |
Re: Addition is left to right in c++. So ob2 and ob3 are added together to form a const A. Then ob1 and that const A returned from the previous addition are added together. [code=c++] ob4 = ob1.operator+( ob2.operator+(ob3) ); [/code] Hope this will clear that up for you. | |
Re: here you go [URL="http://www.google.com/#hl=en&source=hp&q=how+to+read+a+pdf+with+c%2B%2B&aq=f&aqi=&aql=&oq=&gs_rfai=&fp=64619dc89fd6b4ce"]solution[/URL] | |
Re: Personally agree with Narue that the question is misleading. The C++ STL and C's procedural programing have there advantages and disadvantages. I started off writing programs in basic on my TI85 so the first language I learned was a procedural language. Then I moved on to C++ and found a … | |
Re: the problem is with your set1st function. you need to set the member variables to the inputted variables. Also it should be a void function. [code=c++] void set1st(int x1, int y1, char z1) { x = x1; y = y1; z = z1; setBoard(); board[y][x] = z; displayBoard(); } [/code] … | |
Re: you have shape declared in you circle constructor but you don't have circle derived from shape. also you do not have a destructor and you will need one since this class uses dynamic memory. You also have a bunch of methods defined but not declared. maybe this is because you … | |
Re: are you trying to write the class to a file and then read it back? | |
Re: generally if you want the node to hold multiple pieces of data then you should create a class or struct that would hold all of that data and then have the node in the linked list point to a instance of that object. [code=c++] class Foo { int a,b,c,d; }; … | |
Re: Can you get rid of the unlink function in you class? | |
Re: do you have the winmm.lib library linked to this project? [url]http://msdn.microsoft.com/en-us/library/ms712879[/url] | |
Re: Yes you could have them stored in a text file and then have a vector in your sprite class to hold the data. Then if you need it you can read the data from the file and store it into the vector. | |
Re: I'm having a problem trying to run this program. Is there anything special I need to do to run it. the error I'm getting is attached. Also this flagged my sonar protection with Norton but not sure if that matters. | |
Re: Looks like it could be a macro to display text only in debug mode. | |
Re: You are not being a douche bag epicasian. Most people here will not do this for him. We only give homework help to those who show effort. | |
Re: line 15 should be [code=c++] int TNT_DrawSprite(tnt_Player & PlayerRef); [/code] |
The End.