#include <stdio.h>
class Base
{
public:
static void set (bool islive)
{
live = islive;
}
static bool get (){return live;}
private:
static bool live;
};
bool Base::live = true;
int main ()
{
Base::set (false);
puts ( Base::get () ? "live" : "no live");
Base * tp = new Base ();
puts ( tp->get () ? "live" : "no live");
}
结果:
[ace@SSWork Terminal]$ ./a.out
no live
no live
//静态成员在程序一开始的时候进行初始化.
posted on 2006-10-31 14:32
崔少伟 阅读(427)
评论(0) 编辑 收藏 引用 所属分类:
C++