C++ Q48: illegal operation (C33)# JobHunting - 待字闺中
c*e
1 楼
If a class has + and = operator overloaded, and three objects a, b, c
constructed, which of the following is illegal?
a) (c=a+a)=b+c;
b) a=a=b+c;
More detail:
____________________
class X {
public:
X& operator=(const X& rhs);
const X& operator+(const X& rhs) const;
private;
int n;
};
int main() {
X a, b, c;
// Statement goes here
return 0;
}
constructed, which of the following is illegal?
a) (c=a+a)=b+c;
b) a=a=b+c;
More detail:
____________________
class X {
public:
X& operator=(const X& rhs);
const X& operator+(const X& rhs) const;
private;
int n;
};
int main() {
X a, b, c;
// Statement goes here
return 0;
}