fork download
  1. #include <iostream>
  2.  
  3. class Base
  4. {
  5. public:
  6. Base()
  7. {
  8. std::cout << "Base::Base() \n";
  9. }
  10.  
  11. ~Base()
  12. {
  13. std::cout << "Base::~Base() \n";
  14. }
  15. };
  16.  
  17. class Derived : public Base
  18. {
  19. public:
  20. Derived()
  21. {
  22. std::cout << "Derived::Derived() \n";
  23. }
  24.  
  25. ~Derived()
  26. {
  27. std::cout << "Derived::~Derived() \n";
  28. }
  29. };
  30.  
  31. void foo(Base) {}
  32.  
  33. int main()
  34. {
  35. Derived instance;
  36. foo(instance);
  37. }
Success #stdin #stdout 0s 2852KB
stdin
Standard input is empty
stdout
Base::Base() 
Derived::Derived() 
Base::~Base() 
Derived::~Derived() 
Base::~Base()