C++ C++;通告声明

C++ C++;通告声明,c++,C++,在我的主(全局)标题中的类delaractions中有几个循环声明 #包括 #包括 使用名称空间std; 枚举块{黑、白、空、墙}//墙是板的外侧区域(板阵列为21x21,但仅19x19可播放) 枚举目录{上、下、左、右}//我要超载吗!还是-操作员!左=右? struct nextPoint_t//应该使用引用来实现,但需要练习指针 { 上文第*点; 下文第*点; 左点; 右点; }; 课程点 { 私人: piece\u t mType;//这是什么样的观点 国际金融机构; nextPoin

在我的主(全局)标题中的类delaractions中有几个循环声明

#包括
#包括
使用名称空间std;
枚举块{黑、白、空、墙}//墙是板的外侧区域(板阵列为21x21,但仅19x19可播放)
枚举目录{上、下、左、右}//我要超载吗!还是-操作员!左=右?
struct nextPoint_t//应该使用引用来实现,但需要练习指针
{ 
上文第*点;
下文第*点;
左点;
右点;
};
课程点
{
私人:
piece\u t mType;//这是什么样的观点
国际金融机构;
nextPoint\u t mAdjacent;//指向相邻点的点
bool mlibertiescompted;//跟踪自由是否已被计数,对于mCountLiberites()(集合),由mUpdateLiberites()重置;
int mCountLiberties();//通过调用对mAdjacent points等的计数来计算此点的自由人。
void mSetPos(int xPos,int yPos,board_t the board);//设置mAdjacent指向相邻点,
void mSetStructureLiberties(int numLibs);//设置此值,然后Liberties对所有相邻的方块调用此值
公众:
point_t();//数组的无参数构造函数
void mSetUp(int xPos,int yPos,board_t the board);//设置mType,然后调用setPos iFF not WALL type
point_t(intxpos,intypos,board_t theBoard);//构造函数,将其在网格中的位置作为参数
void mUpdateLiberties();//然后调用countLiberties,通过在所有连接点上操作来更新整个连接结构上的liberties
};
班级董事会
{
私人:
玛利角[21][21];
公众:
board_t();//构造函数,通过对点的操作来设置board
};
不要担心我阅读时的评论,我知道我的意思


我想我可以用转发声明来修复它,但它们似乎不起作用,它只是认为我正在重新定义类

好吧,在考虑了这些评论并自己做了一个测试之后,真正的答案是: 您必须使用转发声明,不再使用。:)

#包括
#包括
课程积分;;
班级委员会;
/*其余代码保持不变*/

好的,在考虑了这些评论并自己做了一个测试之后,真正的答案是: 您必须使用转发声明,不再使用。:)

#包括
#包括
课程积分;;
班级委员会;
/*其余代码保持不变*/
#包括
#包括
枚举块{黑、白、空、墙}//墙是板的外侧区域(板阵列为21x21,但仅19x19可播放)
枚举目录{上、下、左、右}//我要超载吗!还是-操作员!左=右?
课程积分;;
struct nextPoint_t//应该使用引用来实现,但需要练习指针
{ 
上文第*点;
下文第*点;
左点;
右点;
};
班级委员会;
课程点
{
私人:
piece\u t mType;//这是什么样的观点
国际金融机构;
nextPoint\u t mAdjacent;//指向相邻点的点
bool mlibertiescompted;//跟踪自由是否已被计数,对于mCountLiberites()(集合),由mUpdateLiberites()重置;
int mCountLiberties();//通过调用对mAdjacent points等的计数来计算此点的自由人。
void mSetPos(int xPos,int yPos,const board_u&t theBoard);//设置mAdjacent指向相邻点,
void mSetStructureLiberties(int numLibs);//设置此值,然后Liberties对所有相邻的方块调用此值
公众:
point_t();//数组的无参数构造函数
void mSetUp(int xPos,int yPos,const board_t&theBoard);//设置mType,然后调用setPos iFF not WALL type
point_t(int xPos,int yPos,const board_t&theBoard);//构造函数,将其在网格中的位置作为参数
void mUpdateLiberties();//然后调用countLiberties,通过在所有连接点上操作来更新整个连接结构上的liberties
};
班级董事会
{
私人:
玛利角[21][21];
公众:
board_t();//构造函数,通过对点的操作来设置board
};
#包括
#包括
枚举块{黑、白、空、墙}//墙是板的外侧区域(板阵列为21x21,但仅19x19可播放)
枚举目录{上、下、左、右}//我要超载吗!还是-操作员!左=右?
课程积分;;
struct nextPoint_t//应该使用引用来实现,但需要练习指针
{ 
上文第*点;
下文第*点;
左点;
右点;
};
班级委员会;
课程点
{
私人:
piece\u t mType;//这是什么样的观点
国际金融机构;
nextPoint\u t mAdjacent;//指向相邻点的点
bool mlibertiescompted;//跟踪自由是否已被计数,对于mCountLiberites()(集合),由mUpdateLiberites()重置;
int mCountLiberties();//通过调用对mAdjacent points等的计数来计算此点的自由人。
void mSetPos(int xPos,int yPos,const board_u&t theBoard);//设置mAdjacent指向相邻点,
void mSetStructureLiberties(int numLibs);//设置此值,然后Liberties对所有相邻的方块调用此值
公众:
point_t();//数组的无参数构造函数
void mSetUp(int xPos,int yPos,const board_t&theBoard);//设置mType,然后调用setPos iFF not WALL type
point_t(int xPos,int yPos,const board_t&theBoard);//构造函数,将其在网格中的位置作为参数
void mUpdateLiberties();//然后调用countLiberties,通过在所有连接点上操作来更新整个连接结构上的liberties
};
班级董事会
{
私人:
玛利角[21][21];
公众:
board_t();//构造函数,通过对点的操作来设置board
};

如果在结构之前编写

class point_t;
这应该能奏效

虽然我不太清楚你为什么那样组织你的课。你的棋盘上已经有了一个数组mArray,所以没有必要在每个点的内部有指向相邻点的指针

电子数据交换
#include <cstdlib>
#include <iostream>

class point_t;
class board_t;

/* Rest of the code stay the same */
#include <cstdlib>
#include <iostream>

enum piece_t {BLACK, WHITE, EMPTY, WALL}; //wall is area out side of board (board array is 21x21 but only 19x19 is playable)
enum dir_t {ABOVE,BELOW,LEFT, RIGHT}; //shall i overload ! or - operatior? !LEFT==RIGHT?

class point_t;

struct nextPoint_t  //should be implimented with references, but need to practice pointer
{ 
  point_t* above;
  point_t* below;
  point_t* left;
  point_t* right;

};


class board_t;

class point_t
{
 private:
  piece_t mType; //what sort of point this is
  int mLiberties;
  nextPoint_t  mAdjacent; // points to adjacent points

  bool mLibertiesCounted; // keeps track of if liberties have been counted, for mCountLiberites() (sets), is reset by mUpdateLiberites(); 

  int mCountLiberties(); //counts this point's liberites, by calling count on mAdjacent points etc.
  void mSetPos(int xPos, int yPos, const board_&t theBoard); //sets up mAdjacent to point to adjacent points,
  void mSetStructureLiberties(int numLibs); // Sets this squares liberites then calls this on all adjacent squares 


 public:
  point_t ();//  parameterless constructor, for arrays
  void mSetUp(int xPos, int yPos, const board_t& theBoard);// sets up mType then calles setPos iFF not WALL type
  point_t (int xPos, int yPos, const board_t& theBoard); //constructor, takes it's position in the grid as a parameter

  void mUpdateLiberties(); // calles countLiberties then, updates liberites on whole of connected structure, by operating pon all conencted points



};

class board_t 
{
 private:
  point_t mArray [21][21];


 public:
  board_t(); //constructor, sets up board by operating on the point_t's

};
class point_t;
enum piece_t {BLACK, WHITE, EMPTY, WALL};
enum dir_t {ABOVE,BELOW,LEFT, RIGHT}; 

class point_t;
class board_t;

struct nextPoint_t
{ 
  point_t* above;
  point_t* below;
  point_t* left;
  point_t* right;
};
void mSetUp(int xPos, int yPos, board_t* theBoard);
class point_t; // used by nextPoint_t
class board_t; // used by point_t

struct nextPoint_t  //should be implimented with references, but need to practice pointer
{ 
  point_t* above; // goes without problems - doesn't need definition of point_t
  point_t* below;
  point_t* left;
  point_t* right;
};

class point_t
{
 private:
  piece_t mType;
  int mLiberties;
  nextPoint_t  mAdjacent;
  bool mLibertiesCounted;

  int mCountLiberties();
  void mSetPos(int xPos, int yPos, board_t theBoard);
  void mSetStructureLiberties(int numLibs); 

 public:
  point_t ();
  void mSetUp(int xPos, int yPos, board_t theBoard);
  point_t (int xPos, int yPos, board_t theBoard);

  void mUpdateLiberties(); 
};

class board_t 
{
 private:
  point_t mArray [21][21];

 public:
  board_t();     
};
// define it either inline in the header, or non-inline in a cpp file
inline void point_t::mSetPos(int xPos, int yPos, board_t theBoard) {
  /* some work... */
}

// same for mSetUp...