Skip to main content
GameDev.net gamedev.net
🔒 Locked

should operator - modifies the object?

Started by alnite Apr 24, 2004 at 5:51 PM 2 replies 200+ views
Original Post
alnite
alnite
object a; object b; b = -a; should the contents of a be changed, or should it stay the same but pass the changed content to b instead?
alnite
alnite
ah ok. thanks.
Zahlman
Zahlman
It is generally expected that unary minus won''t modify the object. As a rule, imagine how it would behave with ints:

int a = 3;
int b = -a;
std::cout << a << std::endl; // Please tell me you expect "3"

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.