水产养殖学专业薪酬:这段C++代码有何错误?编译不能通过

来源:百度文库 编辑:神马品牌网 时间:2024/07/07 09:51:39
#include <iostream>
#include <stdio>
#include <cstdlib>
#include <string>
using namespace std;
class X{
public:

X(int i){cout<<"constructing..."<<i;a=i;}
X(X& x){cout<<"copying..."<<x.a;a=x.a;}
~X(){cout<<"destroying..."<<a;}
protected:
int a;
};
X fa(X x){return x;}
int main(){
X a(1);
X b = fa(a);

cout<<endl;
system("pause");
}

报错:18 D:\Untitled2.cpp no matching function for call to `X::X(X)'