c++ - 在一个文件中未定义对 Class::Class() 和函数的引用? C++

标签 c++ dependencies circular-dependency

一切都编译得很好,我在这里查看了大约 10 个不同的问题,试图解决它,包括 this , this , 和 this .请不要杀了我,我已经用头撞墙大约 3 个小时了。我也尝试过自己构建有问题的文件,它似乎构建得很好,但是当我构建项目时它仍然会抛出相同的错误。

我曾尝试尽可能将包含“.h's”移动到 cpp 文件中,这在大多数情况下都是如此,但仍然无济于事。当我改变

BitBoards *newBoard = new BitBoards;

BitBoards *newBoard;

该行的错误消失了,但它仍然给我 newBoard-> 函数的“ undefined reference ”。

还有什么其他明显或不明显的我应该尝试的吗?

错误在我的逻辑文件中弹出:Ai_Logic.cpp

 //master bitboard for turn
BitBoards *newBoard = new BitBoards;
^^here
//master zobrist object for ai turn
ZobristH *mZobrist = new ZobristH;

//master evaluation object - evaluates board position and gives an int value (- for black)
evaluateBB *mEval = new evaluateBB;

newBoard->constructBoards();
^^and here as well as every instance of newBoard-> below

Ai_Logic.h:

#include <string>
#include <stack>
#include <thread>
class Pieces;
class ZobristH;
class BitBoards;
class MoveGen;
class evaluateBB;
class HashEntry;

class Ai_Logic
{
//stuff
};

Ai_Logic.cpp

#include "ai_logic.h"

#include <algorithm>
#include <stdlib.h>
#include <time.h>
#include <iostream>

#include "externs.h"
#include "move.h"
#include "evaluatebb.h"
#include "bitboards.h"
#include "movegen.h"
#include "zobristh.h"

BitBoards.h

class MoveGen;
class ZobristH;
class Move;

class BitBoards
{
//stuff
};

BitBoards.cpp

#include "bitboards.h"
#include <cmath>
#include <random>
#include <iostream>
#include <string>
#include <cstdio>

#include "externs.h"
#include "movegen.h"    

我认为问题可能来 self 的 MoveGen.h/cpp,但我不完全确定

移动生成.h

#include <iostream>
#include <string>
#include "move.h"

class Pieces;
class BitBoards;
class ZobristH;


class MoveGen
{
//stuff
};

移动生成.cpp

#include "movegen.h"
#include "bitboards.h"
#include "Pieces.h"   

最佳答案

#include bitboards.cpp 

在 Ai_Logic 文件中似乎可以解决问题。完全不知道为什么。

关于c++ - 在一个文件中未定义对 Class::Class() 和函数的引用? C++,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45363891/

相关文章:

c++ - 如何检查应用程序是否在 OpenOnload 下运行?

c++ - CString 到 LPCTSTR 的转换中断了 sql 查询

依赖于另一个模块的 Android NDK 模块

maven-2 - 使用 Maven 2 管理依赖关系

c++ - 循环依赖修复

gradle - Gradle文件重命名导致循环依赖项错误-为什么?

c++ - 线程函数可以访问成员变量吗?

c++ - 使用 gcc 为 lua 编译模块

java - 为什么 Sonar 设计 View 没有显示我的项目的任何依赖项?

交响乐 2 : Resolve circular reference