A-A+
有如下的程序; #include <ctring> #include <iostream>
问题详情
有如下的程序; #include <ctring> #include <iostream> using namespace std; class MyString { public: MyString(const char *s); ~MyString() {delete[]data;} protected: unsigned len; char *data; }; MyString:: MyString (const char *s) { len=strlen(s); data=new char[len+1]; strcpy(data,s); } int main() { MyString a("C++ Programing"); MyString b(a); return 0; } 在运行上面的程序时出错,出错的原因是______ 。
A.构造函数的实参不允许是本类的对象
B.没有定义实现深层复制(深拷贝)的拷贝构造函数
C.构造对象a时实参与形参类型不符
D.系统不能生成缺省的拷贝构造函数请帮忙给出正确答案和分析,谢谢!
参考答案
正确答案:B
解析:类拷贝的相关内容。