2,712 Posted Topics
Re: Talk about classes, inheritance, polymorphism, generic meta programming, virtual and pure virtual functions, operator overloading... and also about the potentially bad problems like "multiple inheritance" and the ways to solve it. | |
Re: All you need to know is the slope formula, and how to create a mx+b line. Do you know how to do that? | |
Re: [QUOTE=death_oclock;1060270]Do you have the exact wording of the problem? You [I]cannot[/I] turn an unordered list into an ordered one without sorting it.[/QUOTE] Yep, not unless you obscure the meaning of "sorting". | |
Re: First define the showBoard. Maybe this will get you started : [code] void showBoard (char t[3][3]) { for(int i = 0; i < 3; i++) { cout<<"---------------------\n"; for(int j = 0; j < 3; j++) { cout << t[i][j] << " | "; } cout<<endl; } cout<<"---------------------\n"; } [/code] Then … | |
Since thanksgiving is soon here, I thought we would have our own daniweb feast, specifically an obscure feast. Remember that only obscure code is valid in our obscure table. I'll start : [code] #include<iostream> #include<string> using namespace std; ostream& ____ = cout; string _____ = "hello";string ______ ("world"); string _______ … | |
Re: do you need to know the size of the char array? If so then add it to the set* prototype. | |
Re: What is wall? How do you have it oriented. Depending of the orientations of the wall, the collision detection will be easy or harder. | |
Re: >>it's not coming out right... can anyone help? I would but can you be more descriptive? | |
Re: [QUOTE=blahbla;1059807]yea thats not a compiler error message. you could say that its a remark, i guess the code i wrote doesnt do what it wants me to. but i dont understand what it wants. what i wrote looks right to me, but it says its wrong so its wrong.[/QUOTE] Is … | |
Re: you are probably reading/writing a invalid memory. | |
![]() | Re: 1. use win32 with directx 2. use win32 with opengl 3. use java with opengl. 4. make a wrapper of win32 in c++ of the things you need, and use either opengl/glut or directx ![]() |
Re: >>litre per 100 km. means : litre / (100 * km ) | |
Re: [QUOTE=PDB1982;1059448]I have to creat a program where the user inputs two large ints, and they are converted into string in order to add them together (assuming they are larger than 20 characters). One thing, is that it tells me to convert the numbers to a string and store it in … | |
Re: >>but I want it to look like this. ** *** **** **** *** ** 1) Make a function called : printStar(int num); Where it prints num of stars : For example a call to printStar(4) would produce : **** or a call to printStar(2) would produce : *** After you … | |
Re: did you try the red book? Alternativly, you give each object a unique color and easily go about selection from there. | |
Re: You don't. Use c++ clock() or if you are on windows, use queryPerformaceCounter. | |
Re: Int this class : [code] //This is the header file figure.h. using std::cout; class figure { public: virtual void center(); void draw(); void erase(); }; void figure::center() { cout << "Centering the Figure"; cout << "\n"; cout << "\n"; [/code] You should make draw a virtual function because you each … | |
Re: The function uses the & operator. That operator makes a variable synonym. For example : [code] int num = 10 ; int &ref_num = num; ref_num = 4; //same as doing num = 4 [/code] So similarly, since this function : [code] istream& read(istream& is, Student_info& s)[/code] Take a look … | |
Re: Before you open it, check if the file is already opened at your save function. | |
Re: your function prototype : [code] void Start(long remainder,long& countZero, long& countOdd, long& countEven);[/code] your function defintion : [code]void start(long remainder,long& countZero, long& countOdd, long& countEven)[/code] The 's' is not capitalize in the second one. Also I do not see any point for makeing this function. Also you forgot '&' before … | |
Re: using structs or classes would be easier and more elegant. What do you think? | |
Re: A picture or an image is made from a sequence of [URL="http://en.wikipedia.org/wiki/Pixel"]pixels[/URL]. | |
Re: Disregarding the header and the bottom of the table and just considering the inside of the table you can simply just do this : [code] for(int i = Max; i >= Min; --i){ //print i //print '!' //print \t //prints (i)*(i-1)*(i-2)*...(1) //print factorial of i //print new line } [/code] | |
Re: You cannot instantiate an abstract class. You cannot instantiate an abstract class. You cannot instantiate an abstract class. You cannot instantiate an abstract class. You cannot instantiate an abstract class. You cannot instantiate an abstract class. You cannot instantiate an abstract class. You cannot instantiate an abstract class. You cannot … | |
Re: [QUOTE=Darth Vader;1058335]I wonder if there is any function that returns the difference in minutes for examples like this: 1300-1515 (135 minutes) 2350-0100 (70 minutes) Is there any timefunction that can have the ability to return the minutedifference ?[/QUOTE] Are you sure those calculations are correct? | |
Re: Just make a function that returns a random lowercase or a random uppercase depending on the parameter. Do you know how to generate random values ? [code] srand( time(0) ); //#include<ctime> needed for time function int randomNum = rand(); [/code] With that in mind generating a random character is easy … | |
Re: Can you use strings? Since you can access the string as an array with the indexing operator, [] . | |
Re: This is when you can use a pointer that takes an refrence. Try adding this : [code] bool list_add(int (&list)[], int& space_used, int max_size, int value) [/code] Now list is an reference variable which happens to be an array. Also only incrementing max_size by 1 is a bad idea. Try … | |
Re: >>PS: i already searched on the internet Then obviously you haven't searched at daniweb. Anyhow, do you first know how to generate a number from a min to max? | |
Re: It's probably reading the extra newline at the end of your file. | |
Re: Yes, look into vectors, not the STL ones but the mathematical ones. | |
Re: how about you give it some thought, first? | |
Re: This shouldn't be this hard. You want to read from a text file of the format : [code] Firstname;Lastname;178 [/code] where the ';' means the word has ended. And you know you will always read firstname, then lastname, then the value. Now first you need to open a file. Of … | |
| |
| |
Re: >>Is there a way to delete the content on the left side of += after each loop ? Can't know for sure without knowing Fr->callEvent type, but Assumming callEvent is a string ? You can just reset it [code] for (int i = 0; i < 3; i++) { Fr->callEvent … | |
Re: Don't forget, that there are also other methods. For example, you can extract character by character. Here is an example of that : [code] #include<iostream> #include<string> #include<fstream> using namespace std; int main() { ifstream iFile("test.txt"); if(!iFile) return -1; char ch = 0; string content = ""; while(iFile.get(ch) ){ content += … | |
Re: You can use the string's [URL="http://www.cplusplus.com/reference/string/string/find/"] find [/URL]method. | |
Re: Normally, the delete function should look like this : [code] void deleteList(Node * headNode) { Node * temp = headNode; while(temp != null){ temp = head->next; delete head; head = temp; } } [/code] I think that should be correct. | |
Re: [code] #include<iostream> using std::cout; struct Test { int i; Test(int j) { i = j; } void show() { cout << i << "\n"; } }; int main() { Test test[3] = { Test(1), Test(2), Test(3) }; test[0].show(); test[1].show(); test[2].show(); return 0; } //prints 1 2 3 [/code] Of course … | |
Re: when you download netbeans make sure you download the JVM as well. Are you creating the project correctly? | |
Re: >>note the question ask to reprint the array but without any repeating number You can use the library sort method and then display the first element. Compare it with its adjacent, if different display it, and repeat. | |
Re: Before I answer, can you show how you tried to do this, so I can get a better feel of what you are trying to achieve. | |
Re: [QUOTE=mrPaul;1055325]Forgive me if im wrong but wouldn't this be a hell of a lot easier in an array? string itemsArray[x][y] itemsArray["pen"][1.99] or something to this effect? without writing some code to parse your alphanumeric string you're going to struggle how your doing it right now i think (imo)[/QUOTE] Wrong. You … | |
Re: For that you need to read multiple books, and even then you won't know everything. But to start out, C++ primer plus is a good book. It goes in details of C++. | |
Re: What exactly do you need help with? A composition is when your class is composed of some object. Here is an example : [code] class Name { public : string aName; }; [/code] since string is a class and aName is an object, then one could say that Name is … | |
Re: Change this : [code] if (num > largest) largest = num; count++; [/code] to this : [code] if (num >= largest) { largest = num; count++; } [/code] And I think it should work. | |
Re: [QUOTE=cole davidson;1051636]Is there a way to do this without using arrays?[/QUOTE] Yep I guess, you can use if statements to sort this. | |
Re: What you should have is make the Product class composed of an another class. The another class should hold all the data thats needed, like name or barcode. Then you can use that as a parameter to in createNewProduct. Is your createNewProduct creating a temporary(initialized to the parameters passed) variable … |
The End.