fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. class F {
  5. public:
  6. F() { cout << "ctor1\n"; }
  7. F(int) { cout << "ctor2\n"; }
  8. ~F() { cout << "dtor\n"; }
  9. };
  10. class Foo
  11. {
  12. F f;
  13. public:
  14. Foo() : f() { cout << "1\n"; }
  15. Foo(int i) : f(i) { Foo(); cout << "2\n"; }
  16. };
  17.  
  18. int main() {
  19. Foo object(1);
  20. return 0;
  21. }
Success #stdin #stdout 0s 3140KB
stdin
Standard input is empty
stdout
ctor2
ctor1
1
dtor
2
dtor