C ++ - 错误:一个声明中有多个类型

时间:2014-05-14 23:24:08

标签: c++ linux makefile

我正在努力制作这个程序。当我编译它时告诉我我有一个错误:在第49行的这个文件中的一个声明中有多个类型。

#ifndef GRIDGAME_H
#define GRIDGAME_H

#include "GameType.h"

class GridGame {
public:
    GridGame();

    ~GridGame();

    enum GameType GetType() { return m_type; }

    void OutputGreeting() const;

    int NumPlayers() const;

    char GetPlayerSymbol(int player) const;

    int GetBoardSize() const;

    /* Returns NULL on good move, else returns err string.
     * Note that this check is game-neutral (at least for TTT and Reversi)
     */
    const char *IsLegalMove(int player, int row, int col) const;

    void OutputBoard() const;


protected:
    GridGame(enum GameType type, const char *name, const char *playerSymbols, int boardSize);

    void DoBasicMove(int player, int row, int col);

    // The only data member that the subclassed games should really
    // need full read/write access to, once game is set up.
    char **m_board;

private:
    enum GameType m_type;
    const char *m_gameName;
    int m_boardSize;
    const char *m_playerSymbols;

};

#endif //GRIDGAME_H

我没有看到任何错误,有人可以帮助我吗?

编辑:第49行是带有分号的最后一个花括号。

1 个答案:

答案 0 :(得分:1)

可能的情况是enum GameType没有被正确宣布,即你的enum可能被宣布为:

enum GameType
{
    First,
    Second,
    //...
    Last
}

问题是enum和任何类型声明在声明结尾处需要一个分号(;),如下所示:

enum GameType
{
    First,
    Second,
    //...
    Last
};