獲取follwoing錯誤,同時設置靜態無功設置靜態枚舉正確方法瓦爾在CPP文件
error: expected primary-expression before '.' token
「GameScene.h」
#ifndef __GAME_SCENE_H__
#define __GAME_SCENE_H__
class Game {
public:
enum InteractionMode {
EDITING,
PLAYING };
static Game::InteractionMode mode;
}
#endif // __GAME_SCENE_H__
「GameScene.cpp」
#include "GameScene.h"
Game *Game::singleton() {
if (_GameSingleton == NULL) {
_GameSingleton = Game::create();
Game::mode = Game::InteractionMode.PLAYING; //error on this line
}
return _GameSingleton;
}
偏離主題,但不應使用保留的名稱,如'__GAME_SCENE_H__'或'_GameSingleton'。 – 2013-03-28 11:37:04
是的,這就對了。我只是用它們在SO上張貼。不在我的實際代碼中。 – asloob 2013-03-28 11:40:09