首页/ 题库 / [单选题]有如下的程序: #include<cst的答案

有如下的程序: #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) {l

单选题
2022-07-11 08:03
A、构造函数的实参不允许是本类的对象
B、没有定义实现深层复制(深拷贝)的复制构造函数
C、构造对象a时实参与形参类型不符
D、系统不能生成默认的复制构造函数
查看答案

正确答案
B

试题解析
解析: C++语宫中当一个新对象被另一个已存在的同类型对象初始化时要调用复制构造函数,语句’MyS- trmg b(a),”符合此条件将调用类MyString的复制构造函数,但是类MyString没有定义此复制构造函数,所以会出错。

标签:
感兴趣题目
下列程序的输出结果是( )。 #include<iostream.h> void main() { char*Str; str="testI"; cout<<str[5]; }
有以下程序 #include<iostream.h> void main( ) { int a=5,b=0,c=0; if(a=b+c) cout<<"* * *" <<endl; else cout<<"$$$"<<endl;} 下列选项叙述正确的是
有如下程序 #include<iostream.h> #define N2 #define M N+1 #define NUM 2*M+1 void main( ) { int i; for(i=1,i<= NUM;i++) cout<<i;} 该程序中的for循环执行的次数是
有以下程序 #include"iostream.h" void main( ) { int i=1,j=1,k=2; if( (j++||k++)&&i++) cout < < i < < "," < < j < < "," < < k; cout< <end1; } 执行后输出结果是
下面程序错误的语句是 #include“iostream.h” ① void main( ) ② { ③ int A=0; ④ int &B; ⑤ B=A; ⑥ cout<<B; ⑦ cout<<A; ⑧ }
下面程序错误的语句是 #include"iostream.h" ① void main() ② { ③ int A=0; ④ int&B; ⑤ B=A; ⑥ cout<<B; ⑦ cout<<A; ⑧ }
下面程序错误的语句是 #include" iostream.h" ① void main( ) ② { ③ int A=0; ④ int & B; ⑤ B=A; ⑥ cout < < B; ⑦ cout < < A; ⑧ }
下面程序错误的语句是 ①#include < iostream.h> ②void main( 0 ③{ ④ int * p = new int[1] ; ⑤ p =9; ⑥ cout <<*p <<end1; ⑦ delete [ ] p; ⑧ }
以下程序的输出结果是 #include<iostream.h> void main( ) { int a=21,b=11; cout<<- -a+b;}
以下程序的输出结果是 #include<iostream.h> void main( ) { char x=040; cout < < (X < < 1) ;}
以下程序的输出结果是 #include<iostream.h> void main() { char x=040; cout<<(x<<1);}
下面程序的结果是 #include<iostream.h> class A { int a; public: A( ):a(1){} void showa( ){cout<<a;} }; class B { int a; public: B( ) :a(2) {}
相关题目
有如下程序 #include<iostream.h> viod main() { int i,sum=0; for(i=1;i<=3;sum++) sum+=i; cout<<sum<<end1; } 该程序的执行结果是 ______。
有以下程序 #include"iostream.h" void main() { inti=l,j=1,k=2; if ((j++{}k++)&&i++) cout<< i << " ," << j << "," << k; cout<<endl; 执行后输出结果是
下列程序的运行结果为( )。 #include<iostream.h> void main() { int a=2; int b=a+1; cou<<afo<<endl; }
下面程序的输出结果是( )。 #include<iostream.h> #include"string.h" void main() {char a[]="Hello Test",b[]="Test"; strcpy(a,b); cout<<a<<end1; } A) B)C) D)
下列程序的输出结果是( )。 #include<iostream.h> #include"string.h" void main() {char a[]="Hello Test",b[]="Test"; strcpy(a,b); cout<<a<<end1; }
下列程序的输出结果为 #include<iostream.h> void main( ) { char * a[ ]={"hello","the","world"}; char * * pa=a; pa++; cout <<*pa<<end1; }
下列程序的输出结果为 #include<iostream.h> void main() { char*a[]={"hello","the","world"}; char**pa=a; pa++; cout<<*pa<<end1; }
有以下程序,程序运行的结果是 ______。 #include<iostream.h> #include<string.h> void main(){ char x[]= "C++" ,y[10]= "C++" ; cout<<sizeof(x)/sizeof(char)<<“,”<<sizeof(y)/sizeof(char); }
下面程序的结果是 #include"iostream.h" void main( ) { char * str; str="test!"; cout<<str[5]; }
下面程序的结果是 #include" iostream.h" void main( ) { char * str; Str="test!"; cout < < str[5]; }
执行下列程序的结果是( )。 #include<iostream.h> void main() { char *str; str="test!"; cout<<str[5]; }
以下程序中,while语句的循环次数是 ______。 #include<iostream.h> viod main() { int i=0; while(i<10) { if(i<1)continue; if(i==5) break; i++; } }
当执行下面的程序时,如果输入ABC,输出结果是 ______。 #include<iostream.h> #include<string.h> void main(){ char ss[10]=“XYZWV”; cin>>ss; strcat(ss,”DEFG”); cout<<ss; }
有以下程序 #include<iostream.h> floatfun(int x,int y) {return(x+y);} void main() {int a=2,b=5,c=8; tout<<fun((int)fun(a+c,b),a-C);} 程序运行后的输出结果是
有以下程序 #include<iostream.h> float fun(int x,int y) {return(x+y);} void main( ) {int a=2,b=5,c=8; cout<<fun((int)fun(a+c,b) ,a-c) ;}程序运行后的输出结果是
有如下的程序: #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) {l
有如下的程序:#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;}在运行上面的程序时出错,出错的原因是( )。
有下列的程序: #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; } 在运行上面的程序时出错,出错的原因是( )。
有如下的程序: #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; } 在运行上面的程序时出错,出错的原因是
有下列的程序: #include<cstring.h> #include<iostream.h> using namespace std; class MyString { public: MyString(const char*s); ~MyString()<delete[]data;} protected: unsigned len; char*data; };
广告位招租WX:84302438

免费的网站请分享给朋友吧