Jump to content
  • Advertisement


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


Problem with overloaded operators...

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

Hi @all, I guess for most of you my problem isn''t a problem at all... but look... I''ve got a class like this :
class StringClass
public :

StringClass operator+(StringClass *CString);
StringClass operator+=(StringClass *CString);

//add some stuff here

I''d like to have both operators, + and += in my class, because it would make it much easier for me to work with those Strings. Because the += operator is very similar to the + operator, I tried to use the + operator in my += operator''s function instead of copying all the code.
StringClass operator+(StringClass *CString)
 StringClass CNewString;
 //plz imagine a huge piece of code here

 return CNewString;

StringClass operator+=(StringClass *CString)
 StringClass CNewString;
 CNewString = this + CString; //doesn''t work... :(

 return CNewString;
But, somehow it doesn''t work! My compiler tells me that there''s no global binary operator "+" defined... how can I make this one work?

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!