fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4.  
  5. class Foo {
  6. public :
  7.  
  8. ~Foo() {
  9. std::cout << "Foo destruct." << std::endl;
  10. }
  11. };
  12.  
  13. class SubFoo : public Foo {
  14. public:
  15.  
  16. ~SubFoo() {
  17. std::cout << "SubFoo destruct." << std::endl;
  18. }
  19. };
  20.  
  21. int main() {
  22. // your code goes here
  23. {
  24. Foo* f = new SubFoo;
  25. delete f;
  26. }
  27. return 0;
  28. }
Success #stdin #stdout 0s 15232KB
stdin
Standard input is empty
stdout
Foo destruct.