fork(3) download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. class base
  5. {
  6. protected:
  7. base() { cout << "base()" << endl; }
  8. };
  9.  
  10. class obj
  11. {
  12. public:
  13. obj(int i) { cout << "obj(" << i << ")" << endl; }
  14. };
  15.  
  16. class derived : public base
  17. {
  18. public:
  19. derived() : o(10), base() { cout << "derived()" << endl;}
  20. private:
  21. obj o;
  22. };
  23.  
  24. int main()
  25. {
  26. derived d;
  27. return 0;
  28. }
Success #stdin #stdout 0s 2852KB
stdin
Standard input is empty
stdout
base()
obj(10)
derived()