有如下程序: include using namespace std class Base{ int b; public: Base(int i) { 有如下程序:include<iostream>using namespace stdclass 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
有如下程序: include using namespace std class Base{ int b; public: Base(int i) {
有如下程序:
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
相关考题:
有如下程序: include using namespace std; class BASE { public 有如下程序: #include<iostream> using namespace std; class BASE { public: ~BASE(){cout<<"BASE";} }; class DERIVED:public BASE { public: ~DERIVED(){cout<<"DERIVED";} }; int main(){DERIVEDx;retum 0;} 执行后的输出结果是A.BASEB.DERIVEDC.BASEDERIVEDD.DERIVEDBASE
有以下程序:include using namespace std; class Base { public: Base() { K=0; } int 有以下程序:include<iostream>using namespace std;class Base{public:Base(){K=0;}int x;};class Derivedl:virtual public Base{public:Derivedl(){x=10;}};class Derived2:virtua1 public Base
有如下程序:include using namespace std;class BASE{public:~BASE(){cout 有如下程序: #include <iostream> using namespace std; class BASE{ public: ~BASE(){cout<<"BASE";} }; class DERIVED:public BASE{ public: ~DERIVED(){cout<<"DERIVED";} }; int main(){DERIVED x;return 0;} 执行后的输出结果是A.BASEB.DERIVEDC.BASEDERIVEDD.DERIVEDBASE
有如下程序:includeusing namespace std;class BASE{public:~BASE( ){cout 有如下程序: #include<iostream> using namespace std; class BASE{ public: ~BASE( ){cout<<"BASE";} }; class DERIVED:public BASE{ public: ~DERIVED( ){cout<<"DERIVED";} }; int main( ){DERIVED x;return 0;} 程序的输出结果是A.BASEB.DERIVEDC.BASEDERIVEDD.DERIVEDBASE
下面程序的输出结果是【】。include using namespace std; class base { protected: int 下面程序的输出结果是【 】。include <iostream>using namespace std;class base{protected:int a;public:base(){cout<<"0":}};class basel: virtual public base{public:base1(){ cout<<"1";}};class base2 : virtual public base{public:base2(){cout<<"2";}};class derived : public base1,public base2{public:derived () {cout<<"3"; }}int main (){derived obj;cout<<end1;return 0;}
有以下程序 include using namespace std; class Base { int a; public: Base(int x) 有以下程序include <iostream>using namespace std;class Base{int a;public:Base(int x){ a=x; }void show(){ cout<<a; }class Derived : public Base{int b;public:Derived(int i) :Base(i+1),b(i){}void show() { cout<<b;};int main (){Base b(5),*pb;Derived d(1);pb=d;pb->show ();return 0;}运行后的打印结果是______。
有如下程序:includeincludeusing namespace std;class BASE{char c;public 有如下程序: #include<iostream>#include<iosream> using namespace std; class BASE{ char c; public; BASE(char n):c(n){} virtual ~ BASE(){cout<<c;} }; class DERIVED; public BASE{ char c; public: DERIVED (char n): BASE (n+1)A.XYB.YXC.XD.Y
有如下程序:include using namespace std;class BASE{public:~BASE() {cout 有如下程序: #include <iostream> using namespace std; class BASE{ public: ~BASE() {cout<<"BASE"; } }; class DERIVED: public BASE { public: ~DERIVED() {cout<;"DERIVED"; } }; int main(){DERIVED x; return 0;} 执行后的输出结果是______ 。A.BASEB.DERIVEDC.BASEDERIVEDD.DERIVEDBASE
有如下程序:includeusing namespace std;class BASE{public:~BASE(){cout 有如下程序: #include<iostream> using namespace std; class BASE{ public: ~BASE(){cout<<"BASE";} }; class DERIVED:public BASE{ public: ~DERIVED(){cout<<"DERIVED";} }; int main(){DERIVED x;return 0;} 执行后的输出结果是( )。A.BASEB.DERIVEDC.BASEDERIVEDD.DERIVEDBASE