Original Post
🔒 Locked
+ operator overload
Advertisement
Sneftel is right, the only way to overload something like that is thru a global operator overload.
You can define a function as a friend function by placing it in the class you want to be friends with, and putting the word "friend" in front of it.
Ex.
You can define a function as a friend function by placing it in the class you want to be friends with, and putting the word "friend" in front of it.
Ex.
class A
{
...
public:
// this function is still global even tho it is in a class
friend A operator+(const char* lhs, const A &rhs); // friend prototype
};
// global overloaded + operator
A operator+(const char* lhs, const A &rhs) { ... }
Topic Locked
This topic has been locked by a moderator. New replies are not allowed.
Sign in to reply to this topic.
Advertisement