fork download
  1. #include <iostream>
  2. #include <iomanip>
  3.  
  4. using namespace std;
  5.  
  6. struct A
  7. {
  8. virtual ~A()
  9. {
  10. cout << "A::~A()\n";
  11. }
  12. };
  13.  
  14. struct B: public A
  15. {
  16. ~B()
  17. {
  18. cout << "B::~B()\n";
  19. }
  20. };
  21.  
  22. struct C: public A
  23. {
  24. ~C()
  25. {
  26. cout << "C::~C()\n";
  27. }
  28. };
  29.  
  30. int main()
  31. {
  32. B* myB=new B;
  33. C* myC=new C;
  34.  
  35. A** array=new A*[2];
  36. array[0]=myB;
  37. array[1]=myC;
  38.  
  39. delete [] array;
  40.  
  41. return 0;
  42. }
  43.  
  44.  
Success #stdin #stdout 0.01s 5392KB
stdin
Standard input is empty
stdout
Standard output is empty