An identifier is the name of a function/object/variable/whatever. That error is telling you that you're trying to call "PlayGame" in your code, but the compiler doesn't know what "PlayGame" is supposed to be.
Either you don't have a function called PlayGame, or it's not visible to the compiler at the time it comes across the line giving you that error. Remember that functions must be declared before they can be used.
#include <whatever>
usingnamespace std;
///////////////////////////////////////////////////////
void PlayGame(); // the "function prototype". Tells the compiler that the function
// exists
// often, prototypes are put in .h files, and #included into one or more .cpp files
///////////////////////////////////////////////////////
int main()
{
PlayGame(); // compiler now knows what PlayGame is, because the prototype
return 0; // was mentioned above
}
///////////////////////////////////////////////////////
void PlayGame()
{
// this is the actual function body for PlayGame, and contains the code
// that gets run when you call PlayGame
}
note the key differences:
- prototypes have no body, and end with a semicolon
- actual function bodies have no semicolon
You can also give a body without a forward declaration if you do this before the function gets called
1 2 3 4 5 6 7 8 9 10 11 12 13
void PlayGame()//this will both declare and implement the function
{
//Your code
}
//Now PlayGame can be used without Compiler or Linker errors
int main()
{
PlayGame();//Call the function
return 0;
}