cpp_overloading - 8BitsCoding/RobotMentor GitHub Wiki
CPP_Overloading
class A {
public:
A& operator=(A& other) {
a = ++other.a;
return *this;
}
const A operator+(const A& other) {
A _result = *this;
_result.a += other.a;
return _result;
}
int a = 0;
};
int main()
{
A a;
A b;
a = b;
// a.operator=(b)와 동일
a + b;
// a.operator+(b)와 동일
}