题目内容
有如下程序:
include<iostream>
using namespace std
class Base{
int b;
public:
Base(int i) {b=i;}
Void disp () {cout<<"Base:b="<<b<<''; }
};
class Base1:virtual public Base{
public:
Base1(int i):Base(i){}
};
class Base2:virtual public Base{
public:
Base2(int i):Base(i){}
};
class Derived:public Basepublic Base1{
int d;
public:
Derived(int i ,int j):Base1(j),Base2(j),【 】
{ d=i; }
void disp() {cout<<"Derived:d="<<d<<' ';}
};
int main()
Derived objD(1,2);objD. disp()
objD. Base::disp();
objD. Base1::disp()
objD. Base2::disp();
return 0;
}
请将程序补充完整,使程序在运行时输出:
Derivd:d=1 Base:b=2 Base:b=2 Base:b=2
查看答案
搜索结果不匹配?点我反馈