下面程序的运行结果是
#include
class base
{
protected:
int a;
public:
base(){ cout <<”0”;}
class basel:virtual base
}
public:
base 1(){cout <<”1”;}
};
class base2:virtual base
{
public:
base2(){cout <<”2”;(
};
class derived:public base1,public base2
{
public:
derived(){cout <<”3”;}
};
void main()
{
derived obj;
cout <
}
A.0123
B.3120
C.0312
D.3012
第1题:
下面程序的运行结果是 #include<iostream.h> class base{ protected: int a; public: base( ){cout<<"0";} }; class basel:virtual base { public: base1( ){cout<<"1";} }; class base2:virtual base{ public:
A.123
B.3120
C.312
D.3012
第2题:
下面程序的运行结果是( )。 #include<iostream.h> classbase{ protected: inta; public: base(){cout<<"0";} }; classbasel:virtualbase{ public: basel(){cout<<"1";} }; classbase2:virtualbase{ public: base2(){cout<<"2";} }; classderived:publicbasel,publicbase2{ public: derived(){cout<<"3";} }; voidmain() { derivedobj; eout<<endl: }
A.0123
B.3120
C.O312
D.3012
第3题:
下面程序的运行结果是 #include<iostream.h> class base{ protected: int a; public: base(){cout <<"0";} }; class basel:virtual base{ public: basel () {cout <<"1";} }; class base2:virtual base{ public: base2(){cout <<"2";} }; class derived:public basel,public base2{ public: derived(){cout <<"3";} }; void main() { derived obj; cout <<end1; }
A.123
B.3120
C.312
D.3012
第4题:
下面程序的打印结果是【 】。
include <iostream>
using namespace std;
class Base
{
public:
Base(int x)
{
a=x;
}
void show()
{
cout<<a;
}
private:
int a;
};
class Derived : public Base
{
public:
Derived(int i) :Base(i+1) ,b(i) { }
void show()
{
cout<<b;
}
private:
int b;
};
int main ( )
{
Base b(5) , *pb;
Derived d(1);
pb=&d;
pb->show();
return 0;
}
第5题:
下面程序的运行结果是( )。 #include<iostream.h> class base{ protected: int a; public: base{cout<<”0”;} }; class basel:virtual base{ public: basel{cout<<”1”;} }; class base2:virtual base i public: base2{cout<<”2”;} }; class derived:public basel,public base2{ public: derived{cout<<”3”;} }; void main derived obj; cout<<endl:
A.0123
B.3120
C.0312
D.3012