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

有如下的程序: #include<cstring> #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; } 在运行上面的程序时出错,出错的原因是

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

正确答案
B

试题解析

标签:
感兴趣题目
有如下的程序: #include<cstring> #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; } 在运行上面的程序时出错,出错的原因是
有如下的程序: #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; };
有以下程序: #include <iostream> #include <string> using namespace std; int main () { char s[]=" 123\"; cout<<strlen (s) <<", "<<sizeof (s) <<end1; return 0; }
有如下程序: #include <iostream> using namespace std; int main() { int *p; *p = 9; cout << "The value at p: " << *p; return 0; } 编译运行程序将出现的情况是( )。
有如下程序: #include <iostream> using namespace std; int main( ){ int*P; *P=9; cout<<"The value at P:"<<*P: return 0; } 编译运行程序将出现的情况是
有如下程序: #include<iostream> using namespace std; int main() { int *p; *p=9; cout<<"The value at p:"<<*p; return 0; } 编译运行程序将出现的情况是( )
有以下程序: #include 〈iostream〉 using namespace std; #define M 10 #define B4 void setstar(char *a, int n) { int i; for (i=0; i
有以下程序: #include <iostream> #include <string> using namespace std; class base { private: char baseName[10]; public: base ( ) { strcpy (baseName, "Base"); } virtual char *myName() {
相关题目
若有如下程序: #include<iostream> using namespace std; class TestClass { public: void who(){cout<<“TestClass”<<endl;} }; class TestClassl:public TestClass { public: void who(){cout<<“TestClassl”<<endl; int main() { TestC
有如下程序: #include <iostream> using namespace std; class AA { public: virtual void f() { cout<< "AA"; } }; class BB : public AA { public: BB() { cout << "BB"; } }; cla
有如下程序: #include <iostream> using namespace std; class XX { protected: int k; public: XX(int n=5):k(n){} ~XX() { cout<<"XX"; } virtual void f() const=0; }; inline void XX::f()
下面程序的输出结果是( )。 #include<iostream> using namespace std; void main() { int a=18; int * p=&a; cout<<* p;}
有如下程序 #include<iostream.h> viod main() { int i,sum=0; for(i=1;i<=3;sum++) sum+=i; cout<<sum<<end1; } 该程序的执行结果是 ______。
有如下程序: #include<iostream> using namespace std; class MyClass{ public: MyClass(){++count;} ~MyClass(){--count;} static int getCount(){return count;} private: static int count; }; int MyClass::count=0; int main(){ MyCl
有如下程序: #include<iostream> using namespace std; class DA{ int k; public: DA(int x=1):k(x){} ~DA(){cout<<k;} }; int main(){ DAd[]={DA(3),DA(3),DA(3)}; DA*p=new DA[2]; delete[]p; return(); } 这个程序的输出结果是( )。
有如下程序: #include <iostream> using namespace std; Class x { protected: int a; public: x() { a=1; } }; class x1 : virtual public x { public: x1() { a+=1; cout<<
有如下程序: #include<iostream) using namespace std; classBase{ public: Base(int x=0){cout<<x;} }; Class Derived:public Base{ public: Derived(int x=0){cout<<x;} private: Base Val; }; int main(){ Derived d(1); return
有如下程序: #include<iostream> using namespace std; class Base{ public: Base(int x=0){cout<<x;} }; class Derived:public Base{ public: Derived(int x=0){cout<<x;} private: Base val; }; int main( ){ Derived d(1); return 0; } 程序的输出结果是
有如下程序: #include <iostream> using namespace std; class Base { public: Base(int x=0) { cout<<x; } } class Derived: public Base{ public: Derived(int x=0) { cout<<x; } private: Base val; }; int main() { Derived d(1); return 0; }程序的输出结果是
有如下程序: #include <iostream> using namespace std; class AA { public: virtual void f() { cout<< "AA"; } }; class BB : public AA { public: BB() { cout << "BB"; } }; cla
有如下程序: #include<iostream>#include<iosream> using namespace std; class BASE{ char c; public; BASE(char n):c(n){} virtual ~ BASE(){cout<<c;} }; class DERIVED; public BASE{ char c; public: DERIVED (char n): BASE (n+1)
有如下程序: #include<iostream> using namespace std; Class Test { public: Test() {n+=2;} ~Test() {n-=3;} static int getNum() {return n;} private: static int n; }; int Test::n=1; int main() { Test*p=new Test;
设程序如下: #include<iostream> using namespace std; int main() { int **p,*q,r=10; q=&r; p=&q; cout<<**p+1<<end1; return 0; } 以上程序的输出结果是( )
有如下程序: #include<iostream> using namespaee std; class VAC{ public: int f( )COUSt{return 3;} int f( ){return 5;} }; int main( ){ VAC vl; const VAC v2; eout<<v1.f( )<<v2.f( ); return 0; } 程序的输出结果是
有如下程序: #include<iostream> using namespace std; class VAC{ public; intf()const{return 3;} int f(){return 5;} }; Int main(){ VAC v1; const VAC v2; cout<<v1.f()<<v2.f(); return 0; } 运行时的输出结果是( )。
有如下程序: #include <iostream> using namespace std; class XX { protected: int k; public: XX(int n=5):k(n){} ~XX() { cout<<"XX"; } virtual void f() const=0; }; inline void XX::f()
下面程序的输出结果是( )。 #include <iostream> using namespace std; void main( ) { int i=8,*p=0; p = &i; coat<<p; }
有如下程序: #include<cstring> #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[1en+1]; strcpy(data,s); } int main( ){ MyString a("C++Progreanfing"); MyString b(A) ; return 0; } 在运行上面的程序时出错,错误的原因是
广告位招租WX:84302438

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