24Nov/09Off
c++ static关键字
static关键词声明成员变量,作用为在所有实例中保存同一个变量.
在.h中这样声明:
class CStage
{
public:
CStage(void);
~CStage(void);
static float key_timer;
static float countdown_timer;
};
在.cpp中这样初始化:
#include "Stage.h"
CStage::CStage(void)
{
}
CStage::~CStage(void)
{
}
float CStage::key_timer = -1.0f;
float CStage::countdown_timer = 180.0f;
