fork(1) download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. struct A {
  5. A(int a){cout<<1;}
  6. A(const A&a = A(1))
  7. {cout<<2;}
  8. A(A& a) {cout<<3;}
  9. ~A() {cout<<'a';}
  10. };
  11.  
  12.  
  13.  
  14. struct B: A {
  15. B(const B& b)
  16. {cout<<4; }
  17. B(int i=0):A(*this)
  18. {cout<<5; }
  19. ~B(){ cout<<'b';}
  20. };
  21.  
  22. int main(){
  23. {cout<< "start";}
  24. {cout<<endl; A a(1);}
  25. {cout<<endl; A a;}
  26. {cout<<endl; B b;}
  27. return 0;
  28. }
  29.  
Success #stdin #stdout 0s 5316KB
stdin
Standard input is empty
stdout
start
1a
12aa
35ba