fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. class MyClass
  5. {
  6. public:
  7. void MyFunc()
  8. {
  9. static bool MyBool = false;
  10. if (!MyBool)
  11. cout << "I'm a happy function!" << endl;
  12. else
  13. cout << "I'm a sad function :(" << endl;
  14. MyBool = true;
  15. }
  16. };
  17.  
  18. int main()
  19. {
  20. MyClass *thing = new MyClass();
  21. thing->MyFunc();
  22. delete thing;
  23. thing = new MyClass();
  24. thing->MyFunc();
  25. delete thing;
  26. }
Success #stdin #stdout 0.02s 2856KB
stdin
Standard input is empty
stdout
I'm a happy function!
I'm a sad function :(