fork download
  1. #include <iostream>
  2.  
  3. class Foo
  4. {
  5. static bool special;
  6.  
  7. bool special_;
  8.  
  9. public:
  10.  
  11. Foo()
  12. {
  13. special_ = special;
  14. special = false;
  15. }
  16.  
  17. void bar()
  18. {
  19. if (special_)
  20. {
  21. std::cout << "okay :)\n";
  22. }
  23. else
  24. {
  25. std::cout << "sorry :(\n";
  26. }
  27. }
  28. };
  29.  
  30. bool Foo::special = true;
  31.  
  32. int main()
  33. {
  34. Foo a;
  35. Foo b;
  36. Foo c;
  37. b.bar();
  38. a.bar();
  39. c.bar();
  40. a.bar();
  41. b.bar();
  42. c.bar();
  43. a.bar();
  44. }
  45.  
Success #stdin #stdout 0.01s 2724KB
stdin
Standard input is empty
stdout
sorry :(
okay :)
sorry :(
okay :)
sorry :(
sorry :(
okay :)