-2

ここに私のヘッダーがあり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

そして私のlevel.cpp

#include "level.h"

std::string getCurrentStepExpression(Level* level) {
    std::string result;
    if (level)
        result = level->stepExpressions.front();
    return result;
}

すべて問題ないようですが、コンパイラは次のように述べています。

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

構造体のフィールドが表示されないのはなぜですか?

4

2 に答える 2

2

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);
};
于 2013-11-06T23:40:37.137 に答える
1

stepExpressions構造体の一部ではありません。追加してみてください。

于 2013-11-06T23:37:57.540 に答える