C++ CPP头文件结构错误

C++ CPP头文件结构错误,c++,struct,header,C++,Struct,Header,这是我的标题level.h: #ifndef LEVEL_H_ #define LEVEL_H_ #include <string> #include <map> #include <queue> #include <list> typedef struct { std::string title; int stepsAmount; std::queue &l

这是我的标题
level.h

#ifndef LEVEL_H_
#define LEVEL_H_
    #include <string>
    #include <map>
    #include <queue>
    #include <list>

    typedef struct {
        std::string title;
        int stepsAmount;
        std::queue <std::list <char> > steps;
        std::queue <std::map <std::string, int> > stepsOptions;
    } Level;
    std::string getCurrentStepExpression(Level* level);
#endif
一切似乎都很好,但Compiler说:

..\level.cpp: In function 'std::string getCurrentStepExpression(Level*)':
..\level.cpp:12:19: error: 'struct Level' has no member named 'stepExpressions'

为什么它看不到my struct的字段?

stepExpressions
不是结构的一部分。
尝试添加它。

您需要将stepExpressions成员或stepExpressions()方法添加到结构级别,并传入一些索引以进行分步查找

struct Level {
    std::string title;
    int stepsAmount;
    std::queue <std::list <char> > steps;
    std::queue <std::map <std::string, int> > stepsOptions;
    /* add the method stepExpressions to your class */
    std::list& stepExpressions(int step);
};
结构级{ std::字符串标题; int stepsAmount; std::队列步骤; std::队列步骤; /*将方法stepExpressions添加到类中*/ 标准::列表和步骤表达式(int-step); };
我认为问题在于“结构级别”没有名为“stepExpressions”的成员。除了在结构级别没有stepExpressions之外,一切都正常。看看,你有步骤选项。哦,天哪,我是个白痴=)front()返回一个队列而不是字符串
struct Level {
    std::string title;
    int stepsAmount;
    std::queue <std::list <char> > steps;
    std::queue <std::map <std::string, int> > stepsOptions;
    /* add the method stepExpressions to your class */
    std::list& stepExpressions(int step);
};