Jump to content
  • Advertisement
Sign in to follow this  
conman

operator overloading needs class type

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

Does anyone know why there must be at least one variable a class type to do operator overloading? something like std::string operator + (const char*, int) is not allowed in C++. Is there a reason for this? Tx! - Constantin

Share this post


Link to post
Share on other sites
Advertisement
Because the operators for the primitive types are already defined. What you're trying to do here is adding an offset to a pointer, which is already defined.

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.

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

Sign me up!