1 class A
2 {
3 public:
4 A(){ printf("A "); }
5 ~A(){ printf("~A "); }
6 };
7
8 class B
9 {
10 public:
11 B(){ printf("B "); }
12 ~B(){ printf("~B "); }
13 A a;
14 };
15
16
17 int _tmain(int argc, _TCHAR* argv[])
18 {
19 B *pB;
20 pB = new B;
21
22 delete pB;
23
24 getchar();
25
26 return 0;
27 }
输出结果是:A B ~B ~A