Sign in to follow this  
conman

operator overloading needs class type

Recommended Posts

conman    181
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
eighty    220
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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this