单选题
C++
题号 #1545884
有如下程序:
#include<iostream>
using namespace std;
class Base1 {
public:
Base1(int d) {cout<<d;}
~Base1(){}
};
class Base2{
public:
Base2(int d) {cout<<d;}
~Base2(){}
};
class Derived:public Base1,Base2{
public:
Derived(int a,int b,int c,int d);
Base1(b),Base2(a),b1(d),b2(c) {}
private:
int b1;
int b2;
};
int main(){
Derived d(1,2,3,4);
return 0;
}
运行时的输出结果是( )。
参考答案
D
答案解析
程序在创建派生类对象d时,分别调用基类Base1和Base1的构造函数。
你可能感兴趣的试题
A.***123***456
B.***123456***
C.***123456
D.123456