开发者

Cascading for overloaded + operator

开发者 https://www.devze.com 2023-01-07 08:11 出处:网络
Here\'s the c开发者_JAVA技巧urrent code: const complex complex::operator+(const complex &right)

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

精彩评论

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