しゅつりょくを求める

3617 ワード

 1 #include <iostream>

 2 

 3 using namespace std;

 4 

 5 class A

 6 {

 7 public:

 8     A()  {    cout<<"A"<<endl;    }

 9     ~A() {    cout<<"~A"<<endl;   }

10 };

11 

12 class B:public A

13 {

14 public:

15     B(A &a):_a(a)

16     {

17         cout<<"B"<<endl;

18     }

19     ~B()

20     {

21         cout<<"~B"<<endl;

22     }

23 private:

24     A _a;

25 };

26 

27 int main(void)

28 {

29     A a;

30     B b(a);

31     return 0;

32 }