Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/129.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ &引用;使用未声明的标识符“;当文件#包含在Xcode中时_C++_Xcode_Undeclared Identifier - Fatal编程技术网

C++ &引用;使用未声明的标识符“;当文件#包含在Xcode中时

C++ &引用;使用未声明的标识符“;当文件#包含在Xcode中时,c++,xcode,undeclared-identifier,C++,Xcode,Undeclared Identifier,我正在设计一个纸牌游戏程序 其中,StartStack是一副牌,StartCard是从牌组底部开始的牌,AnimalCard和ActionCard是可以添加到牌组中的牌类型。然而,我在Xcode中遇到了一些非常奇怪的错误 以下是我的课程: StartStack.hpp: #ifndef StartStack_hpp #define StartStack_hpp // Imports of other classes #include "AnimalCard.h" #include "Start

我正在设计一个纸牌游戏程序

其中,StartStack是一副牌,StartCard是从牌组底部开始的牌,AnimalCard和ActionCard是可以添加到牌组中的牌类型。然而,我在Xcode中遇到了一些非常奇怪的错误

以下是我的课程:

StartStack.hpp:

#ifndef StartStack_hpp
#define StartStack_hpp

// Imports of other classes
#include "AnimalCard.h"
#include "StartCard.hpp"
class ActionCard;

// Imports of frameworks
#include <deque>
#include <stdio.h>
#include <memory>

class StartStack : public AnimalCard{

private:

    deque<shared_ptr<AnimalCard> > sstack;
    StartCard scard;

public:

    StartStack();
    StartStack& operator+= ( std::shared_ptr<ActionCard> );
    StartStack& operator-= ( std::shared_ptr<ActionCard> );
    std::shared_ptr<StartCard> getStartCard();
    char getAnimals(int);
    std::shared_ptr<ActionCard> pop_front() { return sstack.pop_front(); }
    std::shared_ptr<ActionCard> remove_front();
};
此类的错误:

  • 第21行(在“public:”和“virtualQueryResult query()=0;”-空行之间)我得到了“未知类型名称表”
h是一个虚拟类,有一些与卡片相关的方法,到目前为止,QueryResult是空的,只有一个不包含任何内容的构造函数。Player.hpp和NoSplit.hpp也可以编译


我已经调查了Xcode中的相关错误,没有发现与我遇到的问题相关的任何问题。如果有人能提出一些可能有用的建议,我们将不胜感激。

您所有的标题都缺少一个
#endif
。这是复制错误吗?否则这可能是源代码…这是一个复制错误,我的程序中有这些错误。例如,如果“NoSplit.hpp”
#include
s“StartStack.hpp”,可能会发生这种情况。请记住,
#include
仅表示“在此处插入此文件的内容”,它并不比这更聪明。发生这种情况可能是因为您有循环引用;我的意思是,你不能引用一个使用你当前正在使用的类的类。
#ifndef StartCard_hpp
#define StartCard_hpp

// Imports of other classes
#include "NoSplit.hpp"

// Imports of frameworks
#include <stdio.h>
#include <deque>

class StartCard : public NoSplit{

public:

    StartCard();
    char getAnimals(int index){return c;};
};
// Imports of other classes
#include "QueryResult.hpp"
#include "Player.hpp"
#include "NoSplit.hpp"
#include "Table.hpp"

class ActionCard : public NoSplit{

public:

    virtual QueryResult query() = 0;
    virtual void perform(Table&, Player*, QueryResult ) = 0;
};