OK, so Im close to wrapping up my work on this simple C++ Game and now its just a matter of connecting the classes together so to speak so that when a certain event happens, it would start running code from another class.
However my menu is a particularly stubborn problem. Im trying to set it so when the user enters option "1" as their choice it starts running the map code in another C++ file but its having none of it.
It gives me the following 3 errors whenever I try run the code.
1 IntelliSense: transfer of control bypasses initialization of:
variable "A" (declared at line 37) e:\C++ - Copy\Menu_3\Menu_3\Menu.cpp 27 3 Menu_3
2 IntelliSense: class "Map" has no member "standby" e:\C++ - Copy\Menu_3\Menu_3\Menu.cpp 38 6 Menu_3
3 IntelliSense: return value type does not match the function type e:\C++ - Copy\Menu_3\Menu_3\Menu.cpp 46 9 Menu_3
This is my menu code:
#pragma once
#include "Map.h"
#include "Menu.h"
#include <iostream>
#include <string>
using namespace std;
using std::cout;
using std::cin;
using std::endl;
using std::string;
Menu::Menu()
{
}
void menu()
{
int choice;
bool gameOn = true;
while (gameOn != false){
cout << " 1 - Play\n";
cout << " 2 - Quit\n";
cin >> choice;
switch (choice)
{
case 1:
cout << "Your adventure starts now!\n";
system("PAUSE");
cout << "Welcome to ATAG brave adventurer!\n";
system("PAUSE");
//Starts the next part of the game, in this case, the map
Map A;
A.standby();
//Ends the game
case 2:
system("PAUSE");
exit(0);
}
}
return 0;
}
Menu::~Menu()
{
}
FYI, I'm using Visual Studio 2013 in case that helps. Anyone got any advice because this is probably the last thing as far as code goes that's stopping me from finishing the project, and I'd be grateful if someone can tell me how to make those 3 errors go away.