对象数组:Student stu[5]?
这个对象数组是调用了拷贝构造函数吗?
这个对象数组是调用了拷贝构造函数吗?
2016-11-02
Student(const Student &s){ //拷贝构造函数
Name=s.Name;
ID=s.ID;
Sex=s.Sex;
Age=s.Age;
Address=new char[strlen(s.Address)+1];
strcpy(Address,s.Address);
count++;
}
Student stu[5]=
{Student("张三","410521199410173321","河南省"),Student("李斯","412309200212232211",12,"河北省"),
Student("王五","430873199610183345","男","山东省"),Student("赵四","410521199450173341","男",21,"河南省"),
Student("赵刚","400521199450173341","男",21,"河南省")};
Student stu6(stu[4]);
为什么count++在拷贝构造函数中可以实现正确的对象个数,如果是放在重载的构造函数中就是11个对象?
举报