关于cocos2dx定义全局常量的问题

A.h 文件:
#include <stdio.h>
#include “cocos2d.h”

USING_NS_CC;

extern const int GAMEOVER_RESTART;

class A : public CCLayerColor{

}

A.cpp 文件:
#include “GameOverDialog.h”

USING_NS_CC;

extern const int GAMEOVER_RESTART = 1;

bool A::init(){}

=================================================================

我想在另外的cpp中使用…怎么报错了呢??

B.cpp 文件
void B::funA(){

switch (XX) {
    case GAMEOVER_RESTART://这句报错.....
        break;
    case 2:
        break;
}

}

贴图:

我是想定义一些全局常量,方面调用…
请问这个应该怎么写…???

本人菜鸟,才接触Cocos2dx几天,c++就更不用说了,勿喷,
如果犯了一些最基本的错误,望大家不吝赐教…

This is a bit of a mess. In C++ const can be used for several things, like declaring actual constants, and declaring read-only variables.
If you declare:

const int x = 0;
In global, namespace, or local scope, it is a constant. You can use it where constant expressions are required (like case labels or array sizes). However, at class scope or as a function parameter, it’s just a read-only variable.

Additionally, if you declare at class scope:

static const int x = 0;
This is also a constant.

能说中文不…

麻烦给出代码示例…

谢谢!!!

这段是stack Overflow上粘过来的,不是故意要show英文:12:
大致就是换成static const int GAMEOVER_RESTART = 1:10:

多状态的话,为何不用枚举。