0 c++ compiler-errors syntax-error
我在网站的其他地方看到了重载函数和此错误的类似问题,但是这发生在我的所有函数中,我不知道发生了什么或如何解决它.
我不确定是否只是因为我犯了一个基本的语法错误,这个错误已经出现了可怕的错误或者更加险恶的错误.如果有人有任何想法请帮助.
哦,我为这个问题的格式不好道歉,这是我提出的第一个问题.
错误C2084:函数'Node :: Node(Board*,int)'已经有一个正文
node.h(16):参见'{ctor}'的先前定义
Node.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
};
Run Code Online (Sandbox Code Playgroud)
Node.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
}
Run Code Online (Sandbox Code Playgroud)
Ps Board是我制作的另一个类,它与Node有同样的问题.
Luc*_*ore 12
Node(Board* board, int player) {};
Run Code Online (Sandbox Code Playgroud)
应该是
Node(Board* board, int player);
Run Code Online (Sandbox Code Playgroud)
在类定义中.这{}
是一个空的实现,它使另一个定义非法.
其他构造函数和方法也是如此.或者,您可以在类定义中保持实现内联,但是您必须从实现文件中删除它们.