fork(5) download
  1. #include <iostream>
  2.  
  3.  
  4. struct Base
  5. {
  6. virtual void foo()
  7. {
  8. std::cout << "Base::foo" << std::endl;
  9. }
  10. virtual ~Base()
  11. {
  12. foo();
  13. }
  14. };
  15.  
  16.  
  17. struct Derived: Base
  18. {
  19. virtual void foo()
  20. {
  21. std::cout << "Derived::foo" << std::endl;
  22. }
  23. };
  24.  
  25.  
  26.  
  27. int main()
  28. {
  29. Base *p = new Derived();
  30. delete p;
  31. }
Success #stdin #stdout 0s 4368KB
stdin
Standard input is empty
stdout
Base::foo