2,712 Posted Topics

Member Avatar for n.utiu

[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: …

Member Avatar for n.utiu
0
227
Member Avatar for naveedmahar

[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. …

Member Avatar for jonsca
0
230
Member Avatar for Valaraukar

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 …

Member Avatar for Fbody
0
90
Member Avatar for Voltron160

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] …

Member Avatar for LevyDee
0
1K
Member Avatar for kd1987

[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 …

Member Avatar for Fbody
0
96
Member Avatar for hawkoftheeye

>>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.

Member Avatar for hawkoftheeye
0
133
Member Avatar for juuuh333

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 …

Member Avatar for mrnutty
0
122
Member Avatar for sid78669

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 …

Member Avatar for sid78669
0
954
Member Avatar for lgonzo

>>[B] You should always try to write the fastest, smallest code possible before attempting to make it simple and correct[/B] LOL...

Member Avatar for vmanes
0
304
Member Avatar for wwsoft

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]

Member Avatar for wwsoft
0
110
Member Avatar for PSP1202
Member Avatar for WaltP
0
102
Member Avatar for PDB1982

Hint : check your set functions, specifically, check the name of the parameter.

Member Avatar for tetron
0
530
Member Avatar for mik3

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 …

Member Avatar for mik3
0
112
Member Avatar for Hawkpath
Member Avatar for ojung

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 …

Member Avatar for onksssss
0
10K
Member Avatar for gunjan_29

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 …

Member Avatar for WaltP
0
121
Member Avatar for WhyteRyce

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]

Member Avatar for WhyteRyce
0
301
Member Avatar for rahul8590

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.

Member Avatar for mrnutty
0
153
Member Avatar for tomtetlaw
Member Avatar for CreativeCoding

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.

Member Avatar for Excizted
0
134
Member Avatar for mebob

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. …

Member Avatar for Stefano Mtangoo
0
98
Member Avatar for programer25

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.

Member Avatar for mrnutty
0
91
Member Avatar for twalls16
Member Avatar for pranay_agg

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]

Member Avatar for mrnutty
0
527
Member Avatar for Carrots

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 …

Member Avatar for mrnutty
0
134
Member Avatar for charqus

use the [URL="http://www.cplusplus.com/reference/string/string/substr/"] substr [/URL] method.

Member Avatar for tetron
0
680
Member Avatar for sasaB
Member Avatar for CreativeCoding

>> [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 …

Member Avatar for mrnutty
0
121
Member Avatar for ultrAslan

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?

Member Avatar for mrnutty
0
95
Member Avatar for sid78669

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; …

Member Avatar for sid78669
0
158
Member Avatar for ineedhelp:(

>> ([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) …

Member Avatar for mrnutty
0
122
Member Avatar for mebob

[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 …

Member Avatar for mebob
0
120
Member Avatar for greatunknown

>>[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.

Member Avatar for mrnutty
0
107
Member Avatar for M.FARAG

>> 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.

Member Avatar for WaltP
0
112
Member Avatar for crozbme
Member Avatar for icelantic

> `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) …

Member Avatar for StuXYZ
0
118
Member Avatar for romariejhoanna

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 …

Member Avatar for romariejhoanna
0
242
Member Avatar for Nicky4815

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 …

Member Avatar for mrnutty
0
323
Member Avatar for NordCoder

>>[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 …

Member Avatar for NordCoder
0
155
Member Avatar for clutchkiller

[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, …

Member Avatar for clutchkiller
0
89
Member Avatar for dema_sami

[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 …

Member Avatar for mrnutty
-2
80
Member Avatar for missmedude
Member Avatar for sblass92

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]

Member Avatar for sblass92
0
115
Member Avatar for Web_Sailor

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].

Member Avatar for Web_Sailor
0
177
Member Avatar for ETP

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?

Member Avatar for WaltP
0
158
Member Avatar for loststudent88

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 …

Member Avatar for mrnutty
0
322
Member Avatar for kikat

>> Queue<AvlNode> q ; //it would not allow me to do this You meant Queue<AvlNode<int>> q ; //right?

Member Avatar for mrnutty
0
117
Member Avatar for Stefano Mtangoo
Member Avatar for Stefano Mtangoo
0
87
Member Avatar for elainadani
Member Avatar for clutchkiller

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 …

Member Avatar for mrnutty
0
125

The End.