fork download
  1. #include <iostream>
  2.  
  3. void shop()
  4. {
  5. std::cout << "I'm in shop now\n";
  6. }
  7.  
  8. void again()
  9. {
  10. std::cout << "Again() is running...\n";
  11. shop();
  12. std::cout << "Returned to again() after shopping\n";
  13. //again(); commented to make program terminate normally
  14. }
  15.  
  16. void game()
  17. {
  18. std::cout << "game() is running...\n";
  19. shop();
  20. std::cout << "Returned to game() after shopping\n";
  21. again();
  22. }
  23.  
  24. int main()
  25. {
  26. std::cout << "program started\n";
  27. game();
  28. std::cout << "exiting...\n";
  29. }
Success #stdin #stdout 0s 3296KB
stdin
Standard input is empty
stdout
program started
game() is running...
I'm in shop now
Returned to game() after shopping
Again() is running...
I'm in shop now
Returned to again() after shopping
exiting...