Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

LukeSkyRunner

Overloading operators in C++

This topic is 5170 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

Advertisement
All operators, with the exception of the dot operator, the dot-star operator, the scope resolution operator, the ternary operator, and the sizeof operator (yes, sizeof is technically an operator).


"Sneftel is correct, if rather vulgar." --Flarelocke

Share this post


Link to post
Share on other sites
you can overload any operator.

you forgot, among others:

<<, >>, ++, --, +=, -=, *=, /=, probably more. why not just google the web and read a chapter on operator overloading?

-me

Share this post


Link to post
Share on other sites
MSDN List of Overloadable Operators

Especially powerful ones could include (), [], new, and delete. Heck, you can even confuse everyone who looks at your code by overloading the comma operator and using it all the time. Not recommended, of course, but doable.


int Agony() { return *((int*)0); }    Mwahaha... >8)

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

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

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!