fork download
  1. #include <iostream>
  2.  
  3. class P
  4. {
  5. public:
  6. P(int i) : i(i) {
  7. std::cout << "ctor: " << i << std::endl;
  8. }
  9. ~P() {
  10. std::cout << "dtor: " << i << std::endl;
  11. }
  12.  
  13. private:
  14. const int i;
  15. };
  16.  
  17. static void f1() { static P p(1); }
  18. static void f2() { static P p(2); }
  19. static void f3() { static P p(3); }
  20. static void f4() { static P p(4); }
  21.  
  22. int
  23. main(void)
  24. {
  25. f4();
  26. f3();
  27. f1();
  28. f2();
  29. return 0;
  30. }
Success #stdin #stdout 0s 3456KB
stdin
Standard input is empty
stdout
ctor: 4
ctor: 3
ctor: 1
ctor: 2
dtor: 2
dtor: 1
dtor: 3
dtor: 4