This is a discussion on whats wrong with this code? within the C++ Programming forums, part of the General Programming Boards category; stupid..sorry...
Last edited by jcafaro10; 08-06-2007 at 09:20 AM.
Is this a "find five faults"?
1. You are using "ans", whilst the parameter do Draft:raft is called "nans".
2. You are using a bitwise or ('|') rather than a logical or ('||').
3. You will most likely encounter an infinite loop should the "ans" be "y" or "n". And of course, since the while-loop isn't entered if you DON'T enter a "y" or "n" string, the final else is pretty pointless, don't you think. The whole while-loop itself can be removed and aside from not creating an endless loop in your Draft constructor, you'd be fine.
4. I think you'll find that your string isn't containing exactly what you expect - what it contains is a different question.
5. Probably don't need a "cout << endl;" after a cin, as hitting enter on the "cin" will make a newline to the console in itself.
sry, when I had deleted it, there weren't any answers up so I guess he musta been typing it. What a bitwise operator mean? Whats the difference between | and ||
Logical operators evaluate the statement to true or false. Bitwise operators do basically the same thing (if there's a logical counterpart), but on a bit-by-bit basis, resulting in a numerical result.
(If you're on Windows, you may try the OR'ing some pairs of values entered as binary on the calculator.)
I might be wrong.
Quoted more than 1000 times (I hope).Thank you, anon. You sure know how to recognize different types of trees from quite a long way away.