fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. struct foo {
  5. foo() { cout << "foo" << endl; }
  6. ~foo() { cout << "~foo" << endl; }
  7. };
  8.  
  9. void bar()
  10. {
  11. cout << "in bar(drinking)" << endl;
  12. static foo barinstance;
  13. }
  14.  
  15. void baz()
  16. {
  17. cout << "in baz" << endl;
  18. static foo bazinstance;
  19. }
  20.  
  21. int main() {
  22. int a;
  23. cin >> a;
  24. if(a % 2) bar();
  25. if(a % 3) baz();
  26. return 0;
  27. }
Success #stdin #stdout 0s 3148KB
stdin
4
stdout
in baz
foo
~foo