fork download
  1. #include <iostream>
  2.  
  3. class A
  4. {
  5. std::string k;
  6. int j;
  7. public:
  8. A() { std::cout << "ctor A" << std::endl;};
  9. ~A() { std::cout << "dtor A" << std::endl;};
  10. };
  11.  
  12. class B : public A
  13. {
  14. public:
  15. B() { std::cout << "ctor B" << std::endl;};
  16. ~B() {std::cout << "dtor B" << std::endl;};
  17. };
  18.  
  19. int main()
  20. {
  21. {
  22. std::cout << "building an A obj" << std::endl;
  23. A a;
  24. }
  25. {
  26. std::cout << "building a B obj" << std::endl;
  27. B b;
  28. }
  29. return(0);
  30. }
Success #stdin #stdout 0s 2856KB
stdin
Standard input is empty
stdout
building an A obj
ctor A
dtor A
building a  B obj
ctor A
ctor B
dtor B
dtor A