下面程序的输出结果是 #include<iostream.h> class A { public: A( ) {cout < < "construtA" < < endl;} Virtual~A( ) {cout < < "destructA" < < endl;}}; class B: public A { }; class C:public A { }; class D:public B,public C { }; void main( ) { D d;}
A.constructA
B.constructA
C.constructA
D.constructA destructA constructA constructA constructA destructA constructA constrnctA destructA destructA constructA destructA destructA destructA destrctA destructA destructA
第1题:
以下程序的执行结果是______。
include<iostream.h>
class A
{
int a:
public:
void seta(int x) {a=x;}
void showa() {cout<<a<<end1;}
};
class B
{
int b;
public:
void setb(int x) {b=x;}
void showb(){cout<<b<<end1;}
};
第2题:
以下程序执行后的输出结果是 ( )。 #include <iostream.h> class Basel { public: void fun(){ cout<<"Basel"<<end1; } }; class Base2 { public: void fun() { cout<<"Base2"<<end1; } } class Derived : public Basel,public Base2 { }; void main() { Derived Obj; Obj.fun(); }
A.Basel
B.Base2
C.BaselBase2
D.程序产生二义性
第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.h> void main(){ int x=20; int &y=x; cout<<(x==y)<<“”; cout<<(&x==&y)<<end1: }
A.20 20 20 20
B.20 20
C.1 1
D.出错
第5题:
下面程序输出的结果为 #include" iostream.h" class A { public: A( ) { cout < < "CLASS A" < < end1;} ~ A( ) { } }; class B:public A { public: B( ){ cout < < "CLASS B" < < end1;} ~ B( ) { } }; void main( ) { A * p; p=new B; B * q;
A.CLASS A CLASS B
B.CLASS A CLASS B CLASS B
C.CLASS A CLASS B CLASS A CLASS B
D.CLASS A CLASS B CLASS B CLASS B