我在嘗試製作這個程序時遇到了一些麻煩。當我編譯它告訴我,我有一個錯誤:多種類型在一個聲明中的第49行C++ - 錯誤:在一個聲明中有多種類型
#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行是最後一個帶分號的大括號。
很肯定'枚舉遊戲類型的GetType {回報m_type; }'應該是'GameType GetType(){return m_type; }' – shuttle87
@ shuttle87,它仍然是有效的語法,但在C++中不是非常有用。 – chris
@chris,很高興知道,我認爲這在C++中是無效的。 – shuttle87