Here's my code:
Cpp1.cpp:
Code:
#include <iostream.h>
#include "header2.h"
int main()
{
int input;
cout << "What do you want to do?";
for ( ; ; )
{
enum {Enter = 1, Exit = 2};
bool exit = false;
cout << "\n1 - Play Game";
cout << "\n2 - Exit Program";
cout << "\nCommand: ";
cin >> input;
switch (input);
{
case Enter: cout << "Loading. ";
break;
case Exit: exit = true;
break;
}
{
if (exit)
break;
else
continue;
}
return 0;
}
header2.h:
Code:
//This creates a database structure for Character
class Character
{
private:
int HP;
int Exp;
public:
Character();
~Character();
void SetHP(int hit_points_left);
void SetExp(int points);
int GetHP() const;
int GetExp() const;
};
//Constructors and destructors of Character:
Character::Character()
{
HP = 50;
Exp = 0;
}
Character::~Character()
{
}
// Sets Character's HP:
void Character::SetHP(int hit_points_left)
{
HP = hit_points_left;
}
// Retrieves Character's HP:
int Character::GetHP() const
{
return HP;
}
// Sets Character's Experience Points:
void Character::SetExp(int points)
{
Exp = points;
}
// Retrieves Character's Experience Points:
int Character::GetExp() const
{
return Exp;
}
//Creates an object of your Character.
Character You;
//This is the level up database:
int Check_Exp()
{
int your_exp = You.GetExp();
enum {level1 = 20, level2 = 60, level3 = 100};
switch (your_exp)
{
case level1: cout << "Place holder one";
break;
case level2: cout << "Place holder two";
break;
case level3: cout << "Place holder three";
break;
default:cout << "Default";
return your_exp;
}
and it gives me the following errors when I try to build Cpp1.cpp:
Error C2601: 'main' : local function definitions are illegal
Fatal error C1075: end of file found before the left brace '{'
I, and several others looked this over, and can't find anything wrong with this source code. Can anyone see what's wrong with it?