开发者

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 ...
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜