我正在尝试构建一个dos mmorpg,并且已经遇到了一个可能非常明显的问题,但我没有看到它。这是我的代码:
#include <iostream>
#include <string.h>
#include <ostream>
#define yes 1
using namespace std;
class CharacterCreation;
class CharacterAttributes;
int main()
{
CharacterCreation CharCreateobject;
CharCreateobject.CharacterRace();
}
class CharacterCreation
{
public:
void CharacterRace()
{
int Race;
char YesOrNo;
cout << "Are you sure you would like to make a character? " << endl;
cin >> YesOrNo;
cout << "Please enter the number of the race you would like to be " << endl;
cout << "1. Human" << endl << "2. Elf" << endl << "3. Giant" << endl << "4. Griffon" << endl << "5. Dwarf" << endl << "6. Orc" << endl;
cin >> Race;
CharacterAttributes CharAttributObject;
switch (Race)
{
case 1:
cout << "You are a Human." << endl;
CharAttributObject.CharHuman();
break;
case 2:
cout << "You are an Elf." << endl;
case 3:
cout << "You are a Giant." << endl;
case 4:
cout << "You are a Griffon." << endl;
case 5:
cout << "You are a Dwarf." << endl;
case 6:
cout << "You are an Orc." << endl;
}
}
};
class CharacterAttributes
{
public:
void CharHuman()
{
cout << "TEST!" << endl;
}
};
我真的不知道自己做了什么,但我怀疑错误是错误的。 如果你能提供帮助,请告诉我,因为我们将不胜感激!:) 再一次,这是我的错误:
Error C2079: 'CharCreateobject' uses undefined class 'CharacterCreation'
error C2228: left of '.CharacterRace' must have class/struct/union
我也有两个错误。 它看起来像所有错误:
Error C2079: 'CharCreateobject' uses undefined class 'CharacterCreation'
error C2228: left of '.CharacterRace' must have class/struct/union
Error 3 error C2079: 'CharAttributObject' uses undefined class 'CharacterAttributes'
Error 4 error C2228: left of '.CharHuman' must have class/struct/union