我想问一下,如何在另一个类中定义类。在下面的代码中。我尝试以 #define "CCompField.h" 的方式定义它,但它不起作用。:(。我认为这是一个很常见的编程问题,可能在互联网上解决了100000次,但我不知道如何找到它。谢谢帮助。
#ifndef CNEWGAME_H
#define CNEWGAME_H
class CNewGame{
public:
CNewGame();
~CNewGame();
void BeginnerGame();
void IntermediateGame();
void AdviceGame();
void HowToPlay();
void NetGame( int mode );
int MoveInMenu();
protected:
void Intro();
void Animation ();
void Menu(int);
int MoveInNetMenu();
void NetMenu(int);
void HeadOfGame();
template <class T> void BodyOfGame(CCompField & b, T & a);
void FooterOfGame();
};
#endif
它会产生以下错误。
In file included from src/CNewGame.cpp:12:0:
src/CNewGame.h:37:36: error: ‘CCompField’ was not declared in this scope
src/CNewGame.h:37:45: error: ‘b’ was not declared in this scope
src/CNewGame.h:37:50: error: expected primary-expression before ‘&’ token
src/CNewGame.h:37:52: error: ‘a’ was not declared in this scope
src/CNewGame.h:37:53: error: variable or field ‘BodyOfGame’ declared void