fork download
  1.  
  2.  
  3. #include <cstdio> // for printf.
  4.  
  5. struct super_unko
  6. {
  7. virtual void dummy() {};
  8.  
  9. ~super_unko() { std::printf("in super_unko d-tor\n"); }
  10. };
  11.  
  12. struct sub_unko : super_unko
  13. {
  14. virtual void dummy() {};
  15.  
  16. ~sub_unko() { std::printf("in sub_unko d-tor\n"); }
  17. };
  18.  
  19. int main()
  20. {
  21. super_unko *p = new sub_unko;
  22.  
  23. // delete (sub_unko*)p;
  24. delete p;
  25.  
  26. std::getchar();
  27. }
  28.  
Success #stdin #stdout 0s 3032KB
stdin
Standard input is empty
stdout
in super_unko d-tor