fork(1) download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. struct Foo {
  5. Foo (int name) : name_(name){}
  6. ~Foo () { cout << "destruct " << name_ << endl; }
  7. int name_;
  8. };
  9.  
  10. void bar () {
  11. Foo foo1(1);
  12. {
  13. Foo foo2(2);
  14. }
  15. {
  16. Foo foo3(3);
  17. }
  18. }
  19.  
  20. int main() {
  21. bar();
  22. return 0;
  23. }
Success #stdin #stdout 0s 3340KB
stdin
Standard input is empty
stdout
destruct 2
destruct 3
destruct 1