临时对象怎么也可以被赋值?
例如:
#include<iostream>
using namespace std;
class A
{
public:
A(int x = 0) : a(x){}
A& operator=(const A& other)
{
a = other.a;
return *this;
}
private:
int a;
};
A function(A& other)//返回值的类型是A
{
return other;
}
int main()
{
A a1(123);
function(a1) = a1;
system("pause");
return 0;
}