2,712 Posted Topics
Re: In c ( or C++) : 0 is false, and any other number is true. | |
Re: [quote]plzzzzzzzzz tel me basics thing of programing[/quote] [QUOTE=Frederick2;1071822]yaaa gotta make variables, then use ifs and loops is ther anythn else ya gotta know?[/QUOTE] Ya gotta learn english 1st. | |
Re: Maybe this will help : [code] bool save(std::ostream& saveFile, string fileName){ //save data } [/code] | |
Re: >>I think do you have the idea and please help me sir with my project... Not really, care to explain a bit more? | |
Re: >>I m having a lot of errors please help Can you post the errors, and what line it points to? | |
Re: inside the operator*, call the multiply function. | |
Re: [QUOTE=merse;1071562]If I want to define what is a double -> double function pointer I use: [CODE]typedef double (*double_fp1)(double);[/CODE] But what if I would like to distinguish const double -> double it is possible? And the above definition consists the const double -> duble function?[/QUOTE] you mean : [code] const double_fp1 … | |
Re: Pick 1 or 2 or all of them : [URL="http://nehe.gamedev.net/"]Nehe[/URL] [URL="http://sabia.tic.udc.es/gc/practicas/opengl_tut_externos/semwal%20tutorial/indexGLTutorial.html"]http://sabia.tic.udc.es/gc/practicas/opengl_tut_externos/semwal%20tutorial/indexGLTutorial.html[/URL] [URL="http://www.lighthouse3d.com/opengl/glut/"]http://www.lighthouse3d.com/opengl/glut/[/URL] [URL="http://www.swiftless.com/tutorials/opengl/opengltuts.html"]http://www.swiftless.com/tutorials/opengl/opengltuts.html[/URL] [URL="http://www.nullterminator.net/opengl32.html"]http://www.nullterminator.net/opengl32.html[/URL] [URL="http://www.morrowland.com/apron/tut_gl.php"]http://www.morrowland.com/apron/tut_gl.php[/URL] [URL="http://www.falloutsoftware.com/3D-OpenGL-Tutorials.htm"]http://www.falloutsoftware.com/3D-OpenGL-Tutorials.htm[/URL] (very good lighting tutorial ) [URL="http://www.videotutorialsrock.com/"]http://www.videotutorialsrock.com/[/URL] [URL="http://www.pdf-search-engine.com/opengl-red-book-pdf.html"]Free openGL red book[/URL] | |
Re: Posted in the correct thread this time. This is also another way, and still naive. It shows both static_assertion and exceptions. [code] #include<iostream> using namespace std; template<typename Type> struct assert_numeric{ const static int i = 0; }; template<> struct assert_numeric<short> { const static int i = 1; }; template<> struct … | |
Re: [URL="http://gmplib.org/"] This [/URL] is a good library. Try inputting 500! in their sample program and see what you get. P.S : its factorial and not fectorial | |
Re: To make it easier on your self. Make a function that concats two strings. [code] //add two string together and places the result in the result variable void concat(const char *left, const char* right, char * result); [/code] The you can just concat title with first name. Then the result … | |
Re: Good to see you are still keeping up with this. I can give you a tga loader if you want. You can load a tga image. I also have some loadBMP functions that loads images if you need. But anyways, check [URL="http://www.spacesimulator.net/tut3_texturemapping.html"] this [/URL] out first. Its a tutorial for … | |
Re: >>"The vector holds a list of data type int? " the word list has ambiguity. A better term(IMO) would be : The vector contains a container in which the contained container is of type int and the contained container is a stl's list container. | |
Re: From : [code] while ((cin >> ar[i]) && (i < arSize))[/code] To : [code] while ((i < arSize) && (cin >> ar[i]) ) [/code] | |
Re: No but you can adjust I guess. [code] string type; cout<<"Choose Type (int,string,float) : "; cin >> type; if(type == "string"){ myClass<string> stringClass; //do stuff } else if(type == "float"){ myClass<float> floatClass; //do stuff } //and so on. [/code] But C++ does not runtime templates. | |
Re: Put the definition in the same file as the templete header, unless your compiler supports the keyword export. | |
Re: IN line 33, 49, and 87, remove the semicolon so the while loop executes like the above post said. | |
Re: [QUOTE=Ancient Dragon;1068594]An array and a list are two different things. Its a lot easier to sort an array than linked list.[/QUOTE] Depends of the definition of "easier" and relative to whom : [code] int A[4] = {4,5,-1,2}; list<int> B(A,A+5); std::sort(A,A+5); //sort array list.sort(); //sort list [/code] | |
Re: >>I need to write a program that count how many nubers can be divide in a interval from k to n, exemple in a interval from 1 - 10 theare "3" numbers that can be divide with 3, here is my program: Explain a bit more. | |
Re: Since "I started learning C++ November 14th 09!!" Then I would suggest to keep learning it more a while. | |
Re: Use the stl's : [URL="http://www.cplusplus.com/reference/algorithm/set_intersection/"]set_intersection [/URL] , [URL="http://www.cplusplus.com/reference/algorithm/set_difference/"] set_difference [/URL]. They also have other variants of those. | |
Re: >>(all sentences are on one line) why? >> Write a C++ program that indicates whether each line on an input file... | |
Re: The reason why one would use one over the other is for efficiency. Some operations like inserting takes constant time in linked list, while it vectors it might not. The only thing you will learn in school is how to study on your own. To become a good programmer, you … | |
Re: First [code] int n, num; cout << "Enter the Number of matrix -> "; cin >> n; int s[n][n]; [/code] The n variable needs to be constant, unless your compiler allowed it, which is not good. To pass a multidimensional array you need this : [code] const int FIXED_COL = … | |
Re: When you don't specify a copy constructor the compiler does a shallow copy. Which means that it just copies the value from one class to another. [code] MyClass obj ( anotherMyClassObj ); //shallow copy [/code] Now if inside MyClass contains a pointer variable( allocated by new). Then that copy constructor … | |
Re: You will need a GUI for that. Look up allegro,opengl directX. | |
Re: Ok thats a start. Now you need to create a vector of size 26. This is how to do that : [code] vector<int> numberOfOccurance(26,0); //create a vector of size 26 with each element initialized to 0 [/code] After that you need to read in the data character by character. One … | |
Re: Seems fine. Although you might want to Make a const MAX_NUM_OF_NAVY then use that where ever you need it. | |
Re: [QUOTE=thinkersgroup;1065238]Hi i want to friendship with a cut girl if there is anyone intrested reply me plz:*[/QUOTE] This is too funny. One of the few post that made me laugh. You made my day thinkersgroup, anyone see the irony with his name? ![]() | |
Re: Take spanish. Its more popular so you can make more contacts. | |
Re: [code] char lesser_msg[5]; actual_len = strlen(message.c_str()); for (i=0; i<actual_len; i++) { // Pad data lesser_msg[i]=message[i]; } [/code] What happens if the actual_len is greater than 5? | |
Re: This is not right : [code] int sort(int arr[], int vals) { int temp; for(int cnt=0; cnt< (vals-1);cnt++) { if(arr[cnt]>arr[cnt+1]) { temp=arr[cnt]; arr[cnt]=arr[cnt+1]; arr[cnt+1]=temp; } } } [/code] | |
| |
Re: remember sin and cos takes angle in radians. But other than that I don't know whats your problem? | |
Re: Well you cannot just dump some random code( in our perspective) and ask for help without providing us no clue. For a soduko solver, I think recursive backtracking is a ok candidate. Google it. As for your solution, I have no idea what how it works so I cannot help. | |
Re: This function : [code] float Display(int x, int y, int z) { cout << "\tAverage= " << AveXYZ << endl; cout << "\tMaximum= " << maxXYZ << endl; cout << "\tMinimum= " << minXYZ << endl; return 0; } [/code] 1st should be a void function. Seconds you meant : … | |
[URL="http://www.horstmann.com/cpp/pitfalls.html"]This [/URL] is a good read. Read it and learn from it. | |
Re: [QUOTE=GrubSchumi;1064310]Hi, So for this we should rather write [CODE] for(i= 0; i <sizeof(scores) / sizeof(int); i++) [/CODE][/QUOTE] That does not work once this is not done within the array's scope. @OP : just do this : [code] for i = 0; i < arraySize ++i{ for j = i+1; j … | |
Re: What are you trying to again? Just need a bit more explanation. | |
Re: Your prototype : [code] void read_salary(double , int); int max_salary(double, int); [/code] Means that they take a double variable and an int variable. Instead use this : [code] void read_salary(double Array[], int); int max_salary(double Array[], int); [/code] | |
Re: [QUOTE=Narue;1067322][B]>which one is necessary to overload if i would like to make -x understanable for the compiler?[/B] The negation operator is a single argument member function: [code] class foo { public: // Overload negation foo operator- ( const foo& obj ); }; [/code][/QUOTE] That is not overloading the negation operator. … | |
Re: Personally I do not find reading code much helpful. Its usually has little comments, and if not written clearly, then its not-comprehensible. I don't get out of it as much as if I would from reading books, ASKING QUESTIONS, coding or doing other things. But I do once in a … | |
Re: By the example you gave us, this : "mcDonalds car 456 burgerKing 8 clowns are scary money leeking from 56 my pockets I like turtles 1". I would suggest that you should extract the sentence word by word. Then when you extract a word, you need to check if its … | |
Re: But on the other hand the efficiency of these are completely different : [code] //with pointers void DivideBigNumbers(BigNumberClass * num, BigNumberClass * num); //without pointers, just object void DivideBigNumbers(BigNumberClass num, BigNumberClass num); //and there is reference void DivideBigNumbers(BigNumberClass& num, BigNumberClass& num); [/code] | |
Re: This is your call : mystruct s(1.,2.); This is mystruct constructor : mystruct(double z) Either make the constructor : mystruct(double z , double z2); Or make the call : mystruct s(1.0); | |
Re: Can you use strings or char arrays ? One problem is in your binary addition function. Here is how you would add binary numbers : [code] 1 1 1 //carry ------ 1 0 1 + 1 1 ------- 1 0 0 0 [/code] remember 1 + 1 = 0 with … |
The End.