Variable not declared in this Scope

I am working on creating a text based video game for a school project and whenever I try to build and run my program my compiler tells me the string variables in the functions were not declared in that scope.
C:\Users\Owner\Documents\EECS\Project_2\main.cpp||In function `void new_game(int&, int&)':|
C:\Users\Owner\Documents\EECS\Project_2\main.cpp|94|error: `move' was not declared in this scope|
C:\Users\Owner\Documents\EECS\Project_2\main.cpp|94|error: `m' was not declared in this scope|
C:\Users\Owner\Documents\EECS\Project_2\main.cpp||In function `int move_playa(int&, int&)':|
C:\Users\Owner\Documents\EECS\Project_2\main.cpp|116|error: `n' was not declared in this scope|
C:\Users\Owner\Documents\EECS\Project_2\main.cpp|116|error: `north' was not declared in this scope|
C:\Users\Owner\Documents\EECS\Project_2\main.cpp|121|error: `e' was not declared in this scope|
C:\Users\Owner\Documents\EECS\Project_2\main.cpp|121|error: `east' was not declared in this scope|
C:\Users\Owner\Documents\EECS\Project_2\main.cpp|126|error: `s' was not declared in this scope|
C:\Users\Owner\Documents\EECS\Project_2\main.cpp|126|error: `south' was not declared in this scope|
C:\Users\Owner\Documents\EECS\Project_2\main.cpp|131|error: `w' was not declared in this scope|
C:\Users\Owner\Documents\EECS\Project_2\main.cpp|131|error: `west' was not declared in this scope|
C:\Users\Owner\Documents\EECS\Project_2\main.cpp|139|error: expected `;' before '}' token|

||=== Build finished: 11 errors|
I cant understand what I am really doing wrong. Any help would be appreciated.

#include <iostream>
#include <string>

using namespace std;

int game_menu(int choice);
//displays the main menu and allows user to choose an action

void new_game(int &x_coord, int &y_coord);
//Begins a new game along with starting coordinates

void load_game(int &x_coord, int &y_coord);
//Loads a previously saved game

int move_playa(int &x_update, int &y_update);
//allows the character to move

int choice = 0, x = 10, y = 10;
string direction, entered_command;

int main()
{
choice = game_menu(choice);
//displays menu

switch(choice)
{
case 1:
new_game(x, y);
break;
case 2:
load_game(x, y);
break;

case 3:
cout << "Goodbye!\n\n\n";
break;

default:
cout << "Invalid choice!!\n\n";
}

return 0;
}

int game_menu(int choice)
{
cout << "The Senile Identity\n";
cout << "1 - Start New Game\n";
cout << "2 - Load Game\n";
cout << "3 - Exit\n\n";
cout << "Enter your choice: ";
cin >> choice;
return choice;
}

void new_game(int& x_coord, int& y_coord)
{
string entered_command;

cout << "You are a senior citizen and your family has mistakenly\n";
cout << "placed you in the 'Alcatraz Senior Citizen Center'\n";
cout << "You must find a means of escape, and quick\n";
cout << "because tonights tuna surprise and few survive that...\n\n";
cout << endl;
cout << "Enter a command\n";
cin >> entered_command;
if((entered_command == move) || (entered_command == m))
{
move_playa(x, y);
};

return;
}

void load_game(int& x_coord, int& y_coord)
{
cout << "This feature has not yet been implemented.\n";
cout << "Please choose another option." << endl;
return;
}

int move_playa(int& x_update, int& y_update)
{
string direction;

cout << "Which direction would you like to move?\n";
cin >> direction;
if((direction == n) || (direction == north))
{
cout << "You shuffle to the North\n";
y_update = y_update + 1;
}
else if((direction == e) || (direction == east))
{
cout << "You shuffle to the East\n";
x_update = x_update + 1;
}
else if((direction == s) || (direction == south))
{
cout << "You shuffle to the South\n";
y_update = y_update - 1;
}
else if((direction == w) || (direction == west))
{
cout << "You shuffle to the West\n";
x_update = x_update - 1;
}
else
{
cout << "Error enter a valid direction\n"
}
return(x_update, y_update);
}
Last edited on
Use code tags. and post the error message from the compiler so we don't have to work as hard to solve your problem please.
The problem is that you are referencing w, west, etc in the if statements. You haven't ever declared those variables. I happen to think you meant "w", "west", etc.
OH, Alright thanks that helped a lot
Topic archived. No new replies allowed.