为何本题通不过?
//关于无名对象的使用
#include<iostream>
using namespace std;
class X
{
public:
X(int x);
X(X & s);
~X();
};
X::X(int x)
{
cout << "Constructing new X:" << x << endl;
}
X::X(X & s)
{
cout << "Constructing copy of:" << endl;
}
X::~X()
{
cout << "Destructing" << endl;
}
X f(X x)
{
cout << "In function " << endl;
return x;
}
int main()
{
X a(1);
X b=f(X(2)); //这里通不过!
a=f(a);
system("pause");
return 0;
}