Jump to content
  • Advertisement
Sign in to follow this  
Lord_Vader

operator overloading

This topic is 4402 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello all, Can anyone tell me how to overload the unary operator -(or +)? Specifically, I've created a vector class that overloads the - operator so that I can do: vector3 = vector2 - vector1; Now I want to be able to do: vector3 = -vector1; How can I achieve this? Any example? Thanks

Share this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster
How does
V3 = V2 - V1

also equal

V3 = -V1

Share this post


Link to post
Share on other sites
Quote:
Original post by Anonymous Poster
How does
V3 = V2 - V1

also equal

V3 = -V1
He was just saying that he'd already overloaded the binary - operator to perform subtraction, but was unsure of how to overload unary - to perform negation (at least that's how I interpreted it).

Share this post


Link to post
Share on other sites
Quote:
Original post by Anonymous Poster
How does
V3 = V2 - V1

also equal

V3 = -V1


First of all, = doesnt mean EQUAL.
And I meant what exactly jyk understood.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!