c++ override operator equals code example
Example 1: equals operator c++ overlaod
MyClass& MyClass::operator=(const MyClass &rhs) {
if (this != &rhs) {
...
}
return *this;
}
Example 2: c++ operator overloading not equal
lass Fred {
public:
};
if
Fred add(const Fred& x, const Fred& y);
Fred mul(const Fred& x, const Fred& y);
Fred f(const Fred& a, const Fred& b, const Fred& c)
{
return add(add(mul(a,b), mul(b,c)), mul(c,a));
}
else
Fred operator+ (const Fred& x, const Fred& y);
Fred operator* (const Fred& x, const Fred& y);
Fred f(const Fred& a, const Fred& b, const Fred& c)
{
return a*b + b*c + c*a;
}
#endif