单项选择题
有如下程序:
#include<iostream>
using namespace std;
class Base
protected:int i;
public:int j;
;
class Derived:public Base
int m;
public:int n;
;
int main( )
Derived d;
d.i=0; //[1]
d.j=0; //[2]
d.n1=0; //[3]
d.n=0; //[4]
return 0;
其中主函数中有两个赋值语句有错,这两个错误的赋值语句是
A.[1]和[2]
B.[1]和[3]
C.[2]和[3]
D.[2]和[4]
点击查看答案&解析
<上一题
目录
下一题>
热门
试题
单项选择题
如下程序的输出是 #include<iostream> using namespace std; class Base public: Base( )cout<< BB ;f( ); void f( )cout<< Bf ; ; class Derived:public Base public: Derived( )eout<< DD ; void f( )cout<< Df ; ; int main( )Derived d;return 0;
A.BBBff)D
B.BBDfDDDf
C.DD
D.DDBBBf
点击查看答案&解析
单项选择题
有如下程序: #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;
在运行上面的程序时出错,错误的原因是A) 构造函数的实参不允许是本类的对象
B.没有定义实现深层复制(深复制)的复制构造函数
C.构造对象a时实参与形参类型不符
D.系统不能生成缺失的复制构造函数
点击查看答案&解析
相关试题
C++语言中的多态性分为编译时的多态性和...
有如下程序: #include<iostream> usi...
若将一个二元运算符重载为类的成员函数,其...
如下类定义中包含了构造函数和复制构造函数...
有如下程序: #include<iostream> usi...