fork(1) download
  1. #include <stdio.h>
  2.  
  3. class A {
  4. public:
  5. ~A() {
  6. putchar('A');
  7. }
  8. };
  9.  
  10. class B : public A {
  11. public:
  12. ~B() {
  13. putchar('B');
  14. }
  15. };
  16.  
  17. class C {
  18. public:
  19. virtual ~C() {
  20. putchar('C');
  21. }
  22. };
  23.  
  24. class D : public C {
  25. public:
  26. ~D() {
  27. putchar('D');
  28. }
  29. };
  30. class E {
  31. public:
  32. virtual ~E() {
  33. putchar('E');
  34. }
  35. };
  36.  
  37. class F : public E {
  38. public:
  39. virtual ~F() {
  40. putchar('F');
  41. }
  42. };
  43.  
  44. int main() {
  45. puts(" ");
  46. {printf("A: "); A a;}
  47. {printf("\nB: "); B b;}
  48. {printf("\nC: "); C c;}
  49. {printf("\nD: "); D d;}
  50. {printf("\nE: "); E e;}
  51. {printf("\nF: "); F f;}
  52.  
  53. puts(" ");
  54. {printf("\nA: "); delete (new A);}
  55. {printf("\nB: "); delete (new B);}
  56. {printf("\nC: "); delete (new C);}
  57. {printf("\nD: "); delete (new D);}
  58. {printf("\nE: "); delete (new E);}
  59. {printf("\nF: "); delete (new F);}
  60.  
  61. puts(" ");
  62. {printf("\nA: "); delete (new A);}
  63. {printf("\nB: "); delete ((A*)new B);}
  64. {printf("\nC: "); delete (new C);}
  65. {printf("\nD: "); delete ((C*)new D);}
  66. {printf("\nE: "); delete (new E);}
  67. {printf("\nF: "); delete ((F*)new F);}
  68. return 0;
  69. }
Success #stdin #stdout 0s 3460KB
stdin
Standard input is empty
stdout
 
A: A
B: BA
C: C
D: DC
E: E
F: FE 

A: A
B: BA
C: C
D: DC
E: E
F: FE 

A: A
B: A
C: C
D: DC
E: E
F: FE