c++问题
以下代码:
#include <iostream>
using namespace std;
class Test
{
public:
int i;
public:
Test (int n = 0){ i = n; }
Test operator = (Test & t);
};
Test Test::operator = (Test & t)
{
/..../
i = t.i;
/..../
return *this;
}
int main (void)
{
Test t1 (1);
Test t2 (5);
Test t3;
cout << (t3 = t2)= t1).i << endl;
//cout << (t3 = t2).i++ << endl;
return 0;
}
将注释去掉的话,编绎就会出错。
我是在VC下试验的。
错误的意思跟左值有关,由于现在本机上没有VC,也没有GCC,没有贴出错误信息。
求救,谢谢!