#include <iostream>
void shop()
{
std::cout << "I'm in shop now\n";
}
void again()
{
std::cout << "Again() is running...\n";
shop();
std::cout << "Returned to again() after shopping\n";
//again(); commented to make program terminate normally
}
void game()
{
std::cout << "game() is running...\n";
shop();
std::cout << "Returned to game() after shopping\n";
again();
}
int main()
{
std::cout << "program started\n";
game();
std::cout << "exiting...\n";
}
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...
Bro, thanks but I don't want to get pre-made as I wont learn anything off it. It is better when I learn the things step by step. Also, I think you haven't got my point.
I want that from the shop() function, go to the again();, which is after the shop().
It is fine that you want to do it on your own, but you will have to get used to learning to do things from reading and understanding someone else's code at some point because most libraries out there sometimes have poor documentation or no updated tutorials which requires you to read the code and figure out what it is doing.
As pointed out by others, your code is doing multiple calls that aren't needed and from what I can see game() and again() are identical functions. Part of learning is listening to others that know the language. I didn't make my code for you to use, but to learn by understanding my code and what it is doing. For example, my program does the exact same as yours, but does so with only one function call, but also gives the 'player' the ability to exit without clicking the close button. The code I showed can easily have a shop function added to it by simply removing the cases for buying and selling and turning it into a single case for calling shop where you can have code for buying items or selling pokemon.