下面程序的结果是 #include<iostream.h> class A public: A( ) cout < < "construtA" < < end1; virtual ~A( ) cout < < "destructA" < < end1; ; class B:public A ; class C:public A ; class D:public B,public C ; void main( ) Dd;
A: constructA
B: destructA
C: constructA
D: constructA
E: destructA
F: destructA
G: constructA
H: constructA
I: constructA
J: destructA
K: destructA
L: destructA
M: constructA
N: constructA
O: constructA
P: constructA
Q: destructA
R: destructA
S: destructA
T: destructA
A: constructA
B: destructA
C: constructA
D: constructA
E: destructA
F: destructA
G: constructA
H: constructA
I: constructA
J: destructA
K: destructA
L: destructA
M: constructA
N: constructA
O: constructA
P: constructA
Q: destructA
R: destructA
S: destructA
T: destructA
举一反三
- 下面程序的结果是( )。 #include<iostream.h> class A { public: A( ) { cout < < "construtA" < < end1;} virtual ~A( ) { cout < < "destructA" < < end1;} }; class B:public A { }; class C:public A { }; class D:public B,public C { }; void main( ) { Dd;} A: 方法是对象的一部分 B: 方法是预先定义好的操作 C: 方法是对事件的响应 D: 方法用于完成某些特定的功能
- 下面程序的结果是( )。 #include<iostream.h> class A int a; public: A: A():a(1) B: void showa()cout<<a; C: ; D: Class Bint a; E: public: F: B():a(2) G: void showa()cout<<a; H: ); I: class C:public A,public Bint a; J: public: K: C():a(3) L: void showa()cout<<a; M: ; N: void main()C c; O: c.showa(); P: A) 1 Q: B) 2 R: C) 3 S: D) 程序有错误
- 设有以下定义和程序: #include<iostream.h> class A1 public: void show 1() cout<<" class A 1"<<end1; class A2:public A1 public: void show20 cout<<"class A2"<<end1; ; class A3:protected A2 public: void show3() cout<<"class A 1 "<<end1; ; void main() A: A1 obj1;A2 obj2;A3 obj3;则以下不合语法的调用语句是( B: )。A) obj1.show1(); C: B) obj2.show1(); D: C) obj3.show1(); E: D) obj2.show2();
- 有如下程序: #include <iostream> using namespace std; class A public: A: A()couk<"A"; B: ; C: class Bpublic:B()cout<<"B"; D: ; E: class C:public A F: B b; G: public:C() cout<<"C"; H: ; I: int main()C obj; return 0; J: 执行后的输出结果是( K: )。A.CBA L: BAC M: ACB N: ABC
- 写出程序运行结果:_________ #include <iostream.h> class Bas { public: ~Bas() { cout<<"Bas construct"<<endl; } virtual void f()=0; }; class Dev:public Bas { public: ~Dev() { cout<<"Bas construct"<<endl; } virtual void f() { cout<<"Dev::f"<<endl; } }; void main() { Bas *a; Dev p; a=&p; a->f(); }