封闭类的复制构造函数问题
#include <iostream>using namespace std;
class Base {
public:
int k;
Base(int n) :k(n) { }
};
class Big {
public:
int v; Base b;
Big(int n) :v(n),b(n) {};
Big(const Big &x) 编译器提示此处有错误,说Base没有合适的构造函数可用
{
v = x.v;
b = x.b;
}
};
int main() {
Big a1(5); Big a2 = a1;
cout << a1.v << "," << a1.b.k << endl;
cout << a2.v << "," << a2.b.k << endl;
return 0;
}
不是很明白,有没有大神给我讲解一下?感谢!