class X
{
public:
X& operator=(const X& rhs);
const X& operator+(const X& rhs)const;
const X& operator+(int m);
private:
int n;
};
int main()
{
X a,b,c;
//statements go here
return 0;
}
问下面哪个选项的语句是不合法的?
1) a = b + 5;
2) a =a +5 +c;
3) (c=a+a)=b+c;
4) a = b+c+5;
真心不会,求教各位给出正确答案,最好指出错误选项为什么不合法?
...全文
1735打赏收藏
一道关于运算符重载的校园招聘笔试题,求教大侠
class X { public: X& operator=(const X& rhs); const X& operator+(const X& rhs)const; const X& operator+(int m); private: int n; }; int main() { X a,b,c; //statements go here return 0; } 问下面哪个选项的语句是不合法的? 1) a = b + 5; 2) a =a +5 +c; 3) (c=a+a)=b+c; 4