网友您好, 请在下方输入框内输入要搜索的题目:

题目内容 (请给出正确答案)
有如下的程序:include include using namespace std;class MyString{p

有如下的程序: #include <cstring.h> #include <iostream.h> 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.系统不能生成默认的复制构造函数


参考答案

更多 “ 有如下的程序:include include using namespace std;class MyString{p 有如下的程序: #include <cstring.h> #include <iostream.h> 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.系统不能生成默认的复制构造函数 ” 相关考题
考题 下面程序错误的语句是 ① include ② void main( ) ③ { ④ int * p=new int[1] ; ⑤ p 下面程序错误的语句是① #include<iostream.h>② void main( )③ {④ int * p=new int[1] ;⑤ p=9;⑥ cout < < * p < <endl;⑦ delete[ ] p;⑧ }A.④B.⑤C.⑥D.⑦

考题 有如下的程序: #include<cstring.h) #ingclude<iostream.h) using namespace std; Class MyString {public: MyString(const char*s); ~MyString(){delete[]data;} protected: unsigned len; char*data;}; MyString::MyString(const char*S) {lA.构造函数的实参不允许是本类的对象B.没有定义实现深层复制(深拷贝)的复制构造函数C.构造对象a时实参与形参类型不符D.系统不能生成默认的复制构造函数

考题 有下列的程序: include include using namespace std; cl 有下列的程序: #include<cstring.h> #include<iostream.h> 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.系统不能生成默认的复制构造函数

考题 有以下程序includeincludevoid main( ){char*p="abcde\0fghjik\0"; cou 有以下程序 #include<string.h> #include<iostream.h> void main( ) { char*p="abcde\0fghjik\0"; cout<<strlen(p);} 程序运行后的输出结果是A.12B.15C.6D.5

考题 有以下程序:includeincludevoid main( ){char * p="abcde\0fghjik\0";c 有以下程序: #include<string.h> #include<iostream.h> void main( ) { char * p="abcde\0fghjik\0"; cout < < strlen(p) ;} 程序运行后的输出结果是A.12B.15C.6D.5

考题 下列程序的输出结果是______。includeinclude using namespace std;void 下列程序的输出结果是______。include <iostream.h>include <cstring.h>using namespace std;void fun(const char*s,char C) {c=s[strlen (s)/2];}int main {){char str [] ="ABCDE";char ch=str[1];fun(str,sh);cout<<Ch;return 0;}

考题 有下列的程序:includeincludeusing namespace std;class MyString{pub 有下列的程序: #include<cstring.h> #include<iostream.h> using namespace std; class MyString { public: MyString(const char*s); ~MyString()<delete[]data;} protected: unsigned len; char*data; };A.构造函数的实参不允许是本类的对象B.没有定义实现深层复制(深拷贝)的复制构造函数C.构造对象a时实参与形参类型不符D.系统不能生成默认的复制构造函数

考题 有如下的程序:include include using namespace std;class MyString{ 有如下的程序:#include <cstring.h>#include <iostream. h>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); return0;}在运行上面的程序时出错,出错的原因是( )。A.构造函数的实参不允许是本类的对象B.没有定义实现深层复制(深拷贝)的复制构造函数C.构造对象a时实参与形参类型不符D.系统不能生成默认的复制构造函数

考题 下面程序错误的语句是①include ②void main()③{④int * p=new int[1]⑤p=9⑥cout 下面程序错误的语句是①#include<iostream.h>②void main()③{④ int * p=new int[1]⑤ p=9⑥ cout<<* p<<end1;⑦ delete []p;⑧}A.④B.⑤C.⑥D.⑦