Jump to content
  • Advertisement

Archived

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

Lordstar

Problem with overloaded operators...

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

  • 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!