我在网站的其他地方看到过类似的函数重载问题和这个错误,但是这发生在我的所有函数上,我不知道发生了什么或如何解决它。
我不确定是否只是我犯了一个基本的语法错误,这个错误已经严重错误或更险恶。如果有人有任何想法,请提供帮助。
哦,我为这个问题的糟糕格式道歉,这是我问的第一个问题。
错误 C2084:函数 'Node::Node(Board *,int)' 已经有一个主体
node.h(16) : 参见之前对 '{ctor}' 的定义
节点.h
#pragma once
#include "Board.h"
class Node
{
private:
Board* nodeBoard;
int currentPlayer;
int value;
Node** childrenNodes;
public:
//----some constructors----
Node(Board* board, int player) {};
Node(Board* board) {};
~Node(){};
//----other functions----
Node generateChildren(int playerX, int playerY, Board* board) {}
// other functions exist in the same format
};
节点.cpp
#pragma once
#include "Node.h"
Node::Node(Board* board, int player)
{
nodeBoard = board;
currentPlayer = player;
childrenNodes = NULL;
}
Node::Node(Board* board)
{
nodeBoard = board;
}
Node::~Node(){};
Node Node::generateChildren(int playerX, int playerY, Board* board)
{
//this fills the nodes based on if the squares next to the player are moveable
}
Ps Board 是我制作的另一个类,它与 Node.js 有相同的问题。