#include<iostream>
using namespace std;
class Abc
{
public:
int a;
Abc()
{
cout<<"Def cstr called\n";
a=0;
}
Abc(Abc &source)
{
a=source.a;
cout<<"copy constructor is called"<<endl;
}
void operator = (Abc &source)
{
a=source.a;
cout<<"overloaded assignment operator"<<endl;
}
Abc display(Abc ab)
{
cout<<"The a in display "<<ab.a<<endl;
return ab;
}
};
int main()
{
Abc a;
Abc b;
a.a=10;
b=a;
cout<<"b.a ="<<b.a<<endl;
Abc x;
x = (a.display(b));
return 0;
}
在行x =(a.display(b))中我收到編譯錯誤。在評論這條線時它有效。請幫助修改程序以便成功編譯它,並請告訴我在這裏出了什麼問題。由於複製構造函數導致的編譯錯誤
什麼是確切的錯誤信息? – 2012-03-30 08:28:10
http://stackoverflow.com/questions/4172722/what-is-the-rule-of-reeree – Anonymous 2012-03-30 08:28:21