fork(1) download
  1. #include <iostream>
  2. #include <string>
  3. using namespace std;
  4.  
  5. struct Foo
  6. {
  7. string name;
  8. Foo(const string &name):name(name) { cout<<"create "<<name<<endl; }
  9. ~Foo() { cout<<"destroy "<<name<<endl; }
  10. };
  11.  
  12.  
  13. int main()
  14. {
  15. cout<<"1:"<<endl;
  16. Foo a("a");
  17. cout<<"2:"<<endl;
  18. for(int i=0;i<2;++i)
  19. {
  20. cout<<"3:"<<endl;
  21. Foo b(string("b")+(char)('0'+i));
  22. cout<<"4:"<<endl;
  23. }
  24. cout<<"5:"<<endl;
  25. return 0;
  26. }
Success #stdin #stdout 0s 3476KB
stdin
Standard input is empty
stdout
1:
create a
2:
3:
create b0
4:
destroy b0
3:
create b1
4:
destroy b1
5:
destroy a