Witam!
Mam problem z używaniem funkcji void w innych funkcjach void, ponieważ tak jak na załączonym kodzie, kiedy wywołuję funkcję menu_esc() i po wyborze '2' w switchu, funkcja menu_start() nie może zostać wykonana, domyślam się, że dlatego, że jest wyżej w kodzie i komputer jej jakby nie wczytał. Czy jest jakiś sposób na to żeby to obejść ? Może dołączenie innego pliku ? Bo nie mam pojęcia w jaki sposób to zrobić. Chętnie się również dowiem jakie inne błędy popełniłem, z góry dziękuję i pozdrawiam.
#include <iostream>
#include <cstdio>
#include <conio.h>
#include <cstdlib>
using namespace std;
void menu_options(){
cout << "WELCOME TO THE MINT FARM SIMULATOR !!" << endl;
cout << endl;
cout << endl;
cout << "1.CHOOSE A PLANT" << endl;
cout << "2.***IN PROGRESS***" << endl;
cout << "3.***IN PROGRESS***" << endl;
cout << "ESC.BACK TO MENU" << endl;
}
void menu_esc(){
cout << "WELCOME TO THE MINT FARM SIMULATOR !!" << endl;
cout << endl;
cout << endl;
cout << "DO YOU WANT LEAVE THE GAME ?" << endl;
cout << "1.YES" << endl;
cout << "2.NO" << endl;
char choice = getch();
switch(choice)
{
case '1':
exit(0);
break;
case '2':
system("cls");
menu_start();
break;
}
}
void menu_start(){
cout << "WELCOME TO THE MINT FARM SIMULATOR !!" << endl;
cout << endl;
cout << "MENU: " << endl;
cout << "1.NEW GAME" << endl;
cout << "2.LOAD GAME" << endl;
cout << "3.OPTIONS" << endl;
cout << "0.EXIT" << endl;
// cin >> choice;
char choice = getch();
switch(choice)
{
case '1':
system( "cls" );
cout << "1";
break;
case '2':
system( "cls" );
cout << "2";
break;
case '3':
system( "cls" );
menu_options();
break;
case 27:
system( "cls" );
menu_esc();
break;
default:
system( "cls" );
menu_start();
break;
}
}
int main()
{
menu_start();
return 0;
}