2,712 Posted Topics
Re: [QUOTE=n.utiu;1163467]WE have the && operator, the || operator, but xor is only implemented as '^' . And this causes a lot of confusion. Let's take this case: 2 == 2 ^ 2 generates a logical operation instead of bitwise operation , therefore returning a true value. What do yo think: … | |
Re: [QUOTE=kbshibukumar;1162713]Basically, it is a block of code identifies with a name.[/QUOTE] Not completely. Every functions has a domain and a co-domain and its definition. The domain is the valid range of numbers that can be accepted. The co-domain is the valid range of numbers that the function can map to. … | |
Re: Just imagine a ball falling in an uneven ground. Before the ball hits the ground, you have to know some information. Its (x,y) position. Its velocity vector. Its mass. And so on depending how detail the object is represented. As suggested, if the ball falls vertically, then you just take … | |
Re: Let me emphasize this a little more," [B] First I would ask, "WHY?" Why take the slowest sort and slow it down further with the overhead of more function calls and additional memory usage? And, you will have a sort that may overflow the stack on sorting a large array[/B] … | |
Re: [QUOTE=Banfa;1161785]It can be good to return references to objects when you can, for instance the return from operator+= can be a reference. [/quote] Maybe you meant, when overloading the = operator. It doesn't make sense to return a reference when overloading the += operator. [quote] It is not possible to … | |
Re: >>If I erase the nodes from the list (using list::erase) will this delete the actual objects themselves, or just the pointers on the list. It will delete the object, you don't need to worry about freeing the memory any longer. | |
Re: Its there to help you with name conflicts. For example, take this code : [code] namespace A{ void f(){} } namespace B{ void f(){} } [/code] They are fine even though f() is defined twice. You can use either one like so, A::f() or B::f(). Although there is a little … | |
Re: Lets examine this for a second : [code] while(!isEmpty()){ ListNode<char *> *temp = head; head = head->next; head->previous = NULL; delete temp; } [/code] Assume that the list contains, A,B,C. Where A-C can be anything. Now your delete function will do this : //Iteration # 1 1) while(!isEmpty()) is true … | |
Re: >>[B] You should always try to write the fastest, smallest code possible before attempting to make it simple and correct[/B] LOL... | |
Re: Use binary predicate : [code] template<typename Object> struct PointerComp{ bool operator()(const Object* lhs, const Object* rhs)const{ return *lhs < *rhs; } }; //.... std::vector<game_object*> objects; //... std::sort(objects.begin(),object.end(),PointerComp<game_object>()); [/code] | |
Re: [code] cin >> operation; if(operation == 'X') break; [/code] | |
Re: Hint : check your set functions, specifically, check the name of the parameter. | |
Re: See if something like this would work for you : [code] string toString(int num){ stringstream strm; strm << num; return strm.str(); } [/code] Then you can just use each digit like so : [code] string num = toString(125); //num[0] == '1'; //num[1] == '2'; //num[2] == '5'; /* or if … | |
Re: Is there another variable named "b" ? Show more code. | |
Re: You could use tags. For example: //Proper libaries// ... [code] ifstream infile("text.txt") ofstream outfile("search.txt") ... ... ... bool tag=flase; char Word[500]; //Searches word by word; do { cin.getline(Word,500) //check if word matches; if(word[500]=="your word" { tag=true; break; } } while(!infile.eof()); [/code] //So basically search the whole file and keep tab … | |
Re: I am assuming you mean the first word that starts with 'w'. If its a structural sentence, then find the first 'w' Then check if the character before it is a space. If so then its what you are looking for. Be sure to watch out, if w is found … | |
Re: yes you need to clear the stream. Use something like this : [code] #include <limits> #include <string> //... void waitForInput(){ std::cin.ignore(std::numeric_limits<streamsize>::max(),'\n'); string dummy; getline(dummy,'\n'); } [/code] | |
Re: Usually its not a lot, it should be manageable by one person. Can you show some examples of what you mean? Maybe we can help rethink your design. | |
| |
Re: There is a lot to learn. As most things, it will take time and practice. So don't expect it get it soon. There are many comprehensible tutorials about them over the net, so go search them. And maybe come back with a more specific question. | |
Re: Yes. Classes is one way. For example here is a simple Type. [code] class Int{ int val; public: Int() {val = 0;} Int(const int& initVal) { val = initVal; } /* more functions */ }; [/code] You could make it just like a int variable, but it has its difference. … | |
Re: So, I am guessing you learned about structs and classes? If so then go ahead and make a Residential and Commercial class. In fact you can use some inheritance, and polymorphism here, but I guess we can keep it simple. | |
Re: !!!Initialize your variables!!! | |
Re: If you don't need to print out the actual permutations, then you can just calculate the number of different permutation. Maybe something like this would work : [code] return pow(2.0 , double( strlen(str) ) ) - 1; [/code] | |
Re: That doesn't make sense. Why do you derive parent from a GrandParents. Its like saying a parent "is a" GrandParents. Where we know thats not true. A GrandParents, has a [I]child[/I]. A parent has a [I]child[/I]. That suggests composition, not inheritance. And why do you create a Abstract parent class … | |
Re: use the [URL="http://www.cplusplus.com/reference/string/string/substr/"] substr [/URL] method. | |
Re: >>i need to instantiate one of the objects HELP come again? | |
Re: >> [B]But when I run that, the code works other than the fact that it exits out after pause. How do I have it go back to the main "cin"[/B] [code] int cmd = 0; while( cin >> cmd) { if(cmdIsBad()) break; //out of the loop /* else logic goes … | |
Re: Are you referring to [URL="http://en.wikipedia.org/wiki/Methods_of_computing_square_roots#Babylonian_method"] Babylonian method [/URL] for finding the square root of a number? | |
Re: Seems like your mixing java and C++. This code is wrong : [code] #include "Hotel.h" using namespace std; int main() { Hotel *hotels = new Hotel[5]; hotels[0] = new Hotel("Hershey"); hotels[1] = new Hotel("Milton"); hotels[2] = new Hotel("Sheraton"); hotels[3] = new Hotel("BestWestern"); hotels[4] = new Hotel("DaysInn"); for(int i = 0; … | |
Re: >> ([B]L (APR/1200.0) * pow(brac1,N) ) / (pow(brac2,N) - 1.0);[/B] I think you meant, : [code] (L * (APR/1200.0) * pow(brac1,N) ) / ( pow(brac2,N) - 1.0 ); [/code] You know its easier if you do something like this : [code] // (L * (APR/1200.0) * pow(brac1,N) ) / (pow(brac2,N) … | |
Re: [QUOTE=mebob;1153853]her professor says i can help her :-P[/QUOTE] Is your mom really taking an engineering course and you are legit trying to help her? Its hard to believe, although its not unbelievable. The reason I say is that, your mom is mature and she would probably realize that, if she … | |
Re: >>[B]vector<class Note> Measurenum;[/B] Its vector<Note>. You don't put that class keyword. There is no best way. Pick a way that fits the context that its used with. | |
Re: >> I have downloaded a library from this site that deals with Matrix and Complex You do realize that C++ has its own complex class. Why don't you use another application online to verify your answer. | |
Re: >>[B]i != '\0'[/B] BAD idea! | |
Re: > `friend stringArray operator+(const stringArray& left, const stringArray& left);` 1) Does not need to be a friend. 2) Need to implement the assignment operator. stringArray::stringArray(const stringArray& source) { count = source.count; for(int i = 0; i < max_size; i++) { strcpy(storage[i], source.storage[i]); } } 3) Is not implemented correctly. 4) … | |
Re: Ok, get a pencil( or pen) and a paper. Then start adding two numbers. This time instead of brainlessly adding, realize what you are doing in each step. For example, when you add two single digit numbers, you either get 1 single digit number as the answer or you get … | |
Re: I don't trust NEHE code much. Its outdated. If you are going to use someone else's code, why not use a better code than theirs. There are many libraries for printing text in opengl. Pick one an use it. It is much more flexible and you can create better and … | |
Re: >>[B]s a final note I'm wondering whether I should let my ParticleEffect class update all the particles by setting their vaules directly (so basically, the Particle class is public and has no functions) or I should have it call each particle's Update member function.[/B] Go with update() function. And could … | |
Re: [QUOTE=clutchkiller;1153711][code] void NewCustInfo(CustData &cust) { cout << "Customer Name: "; getline(cin, cust.name); } [/code] CustData is a structure that is declared, and the name data member of that struct is of type string. For some reason when I call this function(there are no compile errors), it displays the cout statement, … | |
Re: [QUOTE=dema_sami;1148629]i have abook but i cant solve it if u can help ,it is a home work help me if u can thanx[/QUOTE] Instead of asking random people in the internet, use that money you spent on school, and ask the professor, the teaching assistance, tutors, your friends. Hell you'll … | |
Re: >> secInHour / mph Its backwards. Its mph/secInHour | |
Re: Try something like this : [code] #include <vector> #include <particle.h> using std::vector; int main() { vector <particle*> vec; vec.push_back(new particle()); vec.front()->move(); //option 1 vec[0]->move(); //option 2 } [/code] | |
Re: Also as most times, there is a function for this in algorithm library, in the [URL="http://www.cplusplus.com/reference/algorithm/set_intersection/"] algorithm header.[/URL]. | |
Re: The usual rule around here is that you pay us 100 dollars per an hour. It usually takes us 1-2 hour per homework. So what do you think? | |
Re: First worry about converting hex values into decimal, specifically into R,G,B values in base 10. Suppose the colors in hex, is 0xFF00FF. The first 2 hex values ,FF, is (R)ed. The second 2 hex values, 00 is (G)reen. The third 2 hex values, FF, is (B)lue. Now in general say … | |
Re: >> Queue<AvlNode> q ; //it would not allow me to do this You meant Queue<AvlNode<int>> q ; //right? | |
Re: I read your post, but I'm still confused a little. Can you explain a little more? | |
Re: Hints : 1) Make use of for loops 2) Make use of the mod, % , operator | |
Re: Sorry if its been said already. The keyword class and typename when used in a template function has the same meaning, so they are interchangeable. At first, there was only the keyword class for a template function. The keyword class was used because people did not wan't to add any … |
The End.