Cascading for overloaded + operator
Here's the c开发者_JAVA技巧urrent code:
const complex complex::operator+(const complex &right)
{
complex result;
result.realPart = realPart + right.realPart;
result.imPart = imPart + right.imPart;
return result;
}
How do i modify so that
a = b + c + d;
is allowed?
Make it a const member function:
const complex complex::operator+(const complex &right) const ...
精彩评论