单项选择题
有如下程序: #include<iostream> using namespace std; class Base { pubfic: Base(){cout<<"BB";f();} void f(){cout<<"Bf":} }; class Derived:public Base { public: Derived(){cout<<"DD";) voidf(){cout<<"Df":} }; intmain(){Derived d;retum 0;} 执行上面的程序将输出
A.BBBfDD
B.BBDfDDDf
C.DD
D.DDBBBf
点击查看答案&解析
<上一题
目录
下一题>
热门
试题
单项选择题
有如下程序: #include<iostream> using namespace std; class Demo { public: Demo(){ cout<< default constructor n ;} Demo(const Demo & x){ cout<< copy constructor n :} }; Demo userCode(Demo b){DemoC(b);return c;} int main() { Demo a,d; cout<< calling userCode() n ; d=userCode(a); return 0; } 执行上面程序的过程中,构造函数Demo()和Demo(const Demo &x)被调用的次数分别是
A.1和1
B.1和2
C.2和3
D.2和4
点击查看答案&解析
单项选择题
有如下的程序: #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; } 在运行上面的程序时出错,出错的原因是
A.构造函数的实参不允许是本类的对象
B.没有定义实现深层复制(深拷贝)的拷贝构造函数
C.构造对象a时实参与形参类型不符
D.系统不能生成缺省的拷贝构造函数
点击查看答案&解析
相关试题
有如下程序: #qnclude<iostream> #i...
A
有如下程序: #nclude<iostremn> usin...