下面程序的输出结果是【 】。
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;
}
第1题:
有如下程序: #include<iostream> using namespace std; class Base{ protected: Base(){cout<<'Base';} Base(char c){cout<<c;} }; class Derived:public Base{ public: Derived(char c){cout<<c;} }; int main(){ Derived d('Derived'); return 0; } 执行这个程序屏幕上将显示输出( )。
A.Derived
B.DerivedBase
C.BaseDerived
D.DerivedDerived
第2题:
下面程序的运行结果是 #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
第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> void fun(int & X,inty){intt=x;x=y;y=t;} int main( ){ int a[2]={23,42}; fun(a[1],a[0]); std::cout<<a[0]<<","<<a[1]<<std::endl; return 0; }
A.42,42
B.23,23
C.23,42
D.42,23
第5题:
有如下程序 #include<iostream> using namespace std; class Base{ protected: Base(){cout<<'A';} Base(char c){cout<<c;) }; class Derived: public Base{ public: Derived(char c){cout<<c;) }; int main(){ Derived dl('B'); return 0; } 执行这个程序屏幕上将显示输出( )。
A.B
B.BA
C.AB
D.BB