Object-Oriented Programming Binary Operators
Object-Oriented Programming Binary Operators
(OOP)
Binary operators
►Now suppose:
◦ Complex c2, c3;
Complex t;
t.real = lhs.real + rhs;
t.img = lhs.img;
return t;
}
Binary operators
Complex t;
t.real = lhs + rhs.real;
t.img = rhs.img;
return t;
}
Binary operators
Class Complex{
…
Complex operator + (const
Complex &);
friend Complex operator + (const
Complex &, const double &);
friend Complex operator + (const
double &, const Complex &);
};
Binary operators