fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4.  
  5. class Base {
  6. public:
  7. virtual ~Base() { std::cout << "Base destructor called.\n"; }
  8. };
  9.  
  10. class Derived : public Base {
  11. public:
  12. ~Derived() { std::cout << "Derived destructor called.\n"; }
  13. };
  14.  
  15. int main() {
  16. Base* pBase = new Derived();
  17. delete pBase;
  18. return 0;
  19. }
  20.  
Success #stdin #stdout 0s 5284KB
stdin
Standard input is empty
stdout
Derived destructor called.
Base destructor called.