fork download
  1. //clang 6.0.0
  2.  
  3. #include <iostream>
  4. using namespace std;
  5.  
  6. class Content
  7. {
  8. public:
  9. ~Content()
  10. {
  11. cout << "~Content()" << endl;
  12. }
  13.  
  14. int m_A{0};
  15. int m_B{0};
  16. };
  17.  
  18. class Base
  19. {
  20. public:
  21. virtual ~Base()
  22. {
  23. cout << "~Base()" << endl;
  24. }
  25. };
  26.  
  27. class Derived : public Base
  28. {
  29. public:
  30. Derived()
  31. {
  32. m_ContentPtr = new Content();
  33. }
  34.  
  35. virtual ~Derived()
  36. {
  37. cout << "~Derived()" << endl;
  38. delete m_ContentPtr;
  39. }
  40.  
  41. Content m_Content;
  42. Content* m_ContentPtr;
  43. };
  44.  
  45. int main()
  46. {
  47. Base* d = new Derived();
  48. delete d;
  49. }
Success #stdin #stdout 0s 5628KB
stdin
Standard input is empty
stdout
~Derived()
~Content()
~Content()
~Base()