关于拷贝构造函数
class People{
public:
People(string name){
this->name = name;
cout << "constructing a people" << endl;
}
People(People& p){
this->name = p.getName();
cout << "coping a people" << endl;
}
string getName(){
return name;
}
private:
string name;
};
int main(){
People p("zhouhao");
vector<People> vec;
vec.push_back(p);
cout << vec[0].getName() << endl;
return 0;
}
我在运行的时候老是报错:class 'People' : no copy constructor available
请指教。