有下列的程序: #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; cla有如下程序 #include <iostream> #include <iomanip> using namespace std; class MyClass { public: MyClass() { cout<<'A'; } MyClass(char c){ cout<<c; } ~MyClass(){ cout<<'B'; } }; int main( ) { MyClass p1,*p
[单选题]有如下的程序: include include using namespace st有如下的程序: #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 ch
[单选题]若有以下程序: #include 〈iostream〉 using namespace std; class sample { private: int n; public: sample(){} sample(int m) { n=m; } void addvalue(int m) { sample s; s.n=n+m; *this=s; } void disp() { cout〈〈"n="〈〈n〈〈end1; } }; int main() { sample s(10); s.addv
[单选题]若有以下程序: #include 〈iostream〉 using namespace std; class sample { private: int i; public: void setvalue(int m) { i=m; } void fun(int m) { i+=m; } void disp() { cout〈〈i〈〈end1; } }; int main() { sample *ps; ps=new sample; ps->setvalue(20); ps->fun(
[单选题]若有以下程序: #include 〈iostream〉 using namespace std; class A { private: int x; public: int z; void setx(int i) { x=i; } int getx () { return x; } }; class B : public A { private: int m; public: int p; void setvalue(int a,int b, int C) { setx (A) ; z=b; m
[主观题]如下程序的输出结果是______。 include using namespace std; class Pet{ char nam如下程序的输出结果是______。include<iostream>using namespace std;class Pet{char name[10];public:Pet(char*nanle){strcpy(this->name,name);}const char*getName( )const{return name;}virtual void call(
[主观题]如下程序的输出结果是______。 include using namespace std; class pumpkin{ publ如下程序的输出结果是______。include<iostream>using namespace std;class pumpkin{public:pumpkin( ){++count;}~pumpkin( ){--eount;}static void total_count( ){cout<<count<<"pumpkin(s)"<<endl;}privat
[主观题]如下程序的输出结果是______。 include using namespace std; class Wages{£¯£¯“工资”如下程序的输出结果是______。include<iostream>using namespace std;class Wages{ //“工资”类double base; //基本工资double bonus; //奖金double tax; //税金public:Wages(double CBase,double CBonus,doable CTax):bas
[主观题]如下程序的输出结果是______。 include using namespace std; int funl(int x){retu如下程序的输出结果是______。include<iostream>using namespace std;int funl(int x){return++x;}int fun2(int&x){return++x;}int main( ){int x:1,y=2;Y=funl(fun2(x));cout<<x<<','<<y;return 0;}
[主观题]下面程序运行后输出的结果是()。 include using namespace std; class example{ const下面程序运行后输出的结果是[ ]。include <iostream>using namespace std;class example{const int m;public:example(int i):m(i){}void pr(){cout<<"m="<<m<<endl'}};int main(){example x(100);x.pr();retur