题目内容

假设类X以类Y作为它的一个基类,并且X类和Y类具有相同格式的函数func(),obj为类X的对象,则obj.func()语句实现的功能为( )。

A. 先执行类X的func(),再执行类Y的func()
B. 先执行类Y的func(),再执行类X的func()
C. 执行类X的func()
D. 执行类Y的func()

查看答案
更多问题

下列程序中,划线处正确的语句是()。#includeusing namespace std;class Base{public:void fun() {cout<<”Base::fun”<

A. fun()
Base.fun()
C. Base::fun()
D. Base->fun()

下列程序中,编译时不会出错的语句是()。#includeusing namespace std;class Base{public:Base(){}Base(int i){data=i;}private:int data;};class Derived:public Base{public:Derived():Base(0)Derived(int x):Base(x)};int main(){ Derived d1(1);Base *pb,b1;pb=&d1 //Ad1=b1; //BBase &refB=d1;Derived d2=*pb; //CDerived &refD=refB //Dreturn 0;}

A. pb=&d1
B. d1=b1;
C. Derived d2=*pb;
Derived &refD=refB

请将如下程序补充完整,使程序的输出结果为:B0:1B1:2B2:3D:123源程序清单:#include using namespace std;class B0{ public:B0(int x){a=x;}void f (){cout<<"B0:"<

请将如下程序补充完整,使程序的输出结果为:b=0,d=0b=1,d=2源程序清单:#include using namespace std;class Base{ public:[1] {b=x;}protected:int b;};class Derived: public Base{ int d;public:Derived():d(0){}Derived(int m,int n): [2] {}void print(){cout<<"b="<

答案查题题库