Why in C++ the prefix return a reference but the postfix return a value?
+3
A:
Because with prefix you modify the object and then return it (so it can be lvalue), and with postfix you return the unchanged object (i.e. a copy) and only then update it (this is of course done by first storing the copy in a temporary, updating the original object, and then returning the temporary by value.)
Nikolai N Fetissov
2010-02-23 03:19:43
A:
theoretically u cant (or shouldnt) refer to non-existent but if u want to it, use wild/null pointer. its a guaranteed access violation /facepalm
YeenFei
2010-02-23 03:26:12
What are you talking about?
SLaks
2010-02-23 03:28:24
apparently the author changed the topic right after i replied.look at vava response you will realise he was asking for method to returning reference of non-existence object
YeenFei
2010-03-03 05:49:48