Why do we have x++ when in some cases it doesn't even work. Why can't we have just ++x. When do I use ++x and when do I use x++?
Why do we have x++ when in some cases it doesn't even work. Why can't we have just ++x. When do I use ++x and when do I use x++?
What is the difference between x++ and ++x?Originally Posted by etricity
We could, but we don't.Originally Posted by etricity
If you are using them standalone in a statement, then you should always prefer ++x because if x is of a type for which both prefix and postfix forms of operator++ have been overloaded, then it is likely that the postfix version does more work than the prefix version, and may in fact call the prefix version.Originally Posted by etricity
In other cases, refer to my previous question: what is the difference between x++ and ++x?
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)
My homepage
Advice: Take only as directed - If symptoms persist, please see your debugger
Linus Torvalds: "But it clearly is the only right way. The fact that everybody else does it some other way only means that they are wrong"
I think he meant, "doesn't work in the way that I intended it to."