更多"在派生类中,对类对象成员,基类成员和非类对象成员的初始化程序是____"的相关试题:
[填空题]在派生类中,对类对象成员,基类成员和非类对象成员的初始化程序是 【7】 。
[填空题]在派生类中,对类对象成员,基类成员和非类对象成员的初始化程序是______。
[填空题]在一个派生类中,对基类成员、类对象成员和非类对象成员的初始化次序是先 【14】 ,后 【15】 ,最后为 【16】 。
[填空题]如果不使用多态机制,那么通过基类的指针虽然可以指向派生类对象,但是只能访问从基类继承的成员。下列程序没有使用多态机制,其输出结果是______。
#include<iostream>
using namespace std;
class Base
public:
void print( ) cout<<’B’;;
class Derived:public Base
public:
void print( ) cout<<’D’;;
int main( )
Derived*pd=new Derived( )"
Base*pb=pd;
pb->print( );
pd->print( );
delete pd;
return 0;
[单项选择]派生类对象对其基类中的什么成员是可访问的( )
A. 公有继承的私有成员
B. 私有继承的公有成员
C. 私有继承的保护成员
D. 保护继承的保护成员
[填空题]如果不使用多态机制,那么通过基数的指针虽然可以指向派生类对象,但是只能访问从基类继承的成员。下列程序没有使用多态机制,其输出结果是【 】。
#include
using namespace std;
class Base{
public:
void print( ){cout<<′B′;}};
class Derived:public Base{
public:
void print( ){cout<<′D′;}}
int main( )
{
Derived*pd=new Derived( );
Base*pb=pd;
pb->print( );
pd->print( );
delete pd;
retum 0:
}
[单项选择]如果不使用多态机制,那么通过基类的指针虽然可以指向派生类对象,但是只能访问从基类继承的成员。有如下程序,没有使用多态机制:
#include <iostream>
using namespace std;
class Base
int a,b;
public:
Base(int x,inty)a=x;b=y;
void show( )cout<<a<<’,’<<b<<endl;
;
class Derived:public Base
int C,d;
public:
Derived(int x,int y,int z,intm):Base(x,y)c=z;d=m;
void show( )cout<<c<<’,’<<d<<endl;
.
int main( )
Base BI(50,50),*pb;
Derived D1(10,20,30,40);
pb=&D1;
pb->show( );
return 0;
程序的输出结果是
A. 10,20
B. 30,40
C. 20,30
D. 50,50
[填空题]赋值兼容规则是指在公有派生情况下,基类对象______(能、不能)使用派生类对象。
[填空题]如果不能使用多态机制,那么通过基类的指针虽然可以指向派生类对象,但是只能访问从基数继承的成员,下列程序没有使用多态机制,其输出结果是__________。
#include
using namespace std;
class Base{
public:
Void print( ){cout<< ‘B’;}};
class Derived: public Base{
public
void print( ){cout<< ‘D’;}}
int main( )
{
Derived*pd=new Dreived);
Base*pb=pd;
pb->print( );
pd->print( );
delete pd;
return 0;
}