views:

74

answers:

1

Here's the current 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?

+4  A: 

Make it a const member function:

const complex complex::operator+(const complex &right) const ...
Marcelo Cantos