Global(static) variable initialization question# Programming - 葵花宝典
c*e
1 楼
I wrote a small piece of code, if you run sbin, the out put is 0 however if
you run shbin the out put is one , which is what i expect...
can not figure out why. Thanks,
///////////////////////////////////////////
//lib.h
#include
#include
#include
template
class SingleTon
{
public:
static T * instance ();
protected:
SingleTon () {}
static T * instance_;
};
class A : public SingleTon
{
public:
A () {}
int size () { return box_.size (); }
void
you run shbin the out put is one , which is what i expect...
can not figure out why. Thanks,
///////////////////////////////////////////
//lib.h
#include
#include
#include
template
class SingleTon
{
public:
static T * instance ();
protected:
SingleTon () {}
static T * instance_;
};
class A : public SingleTon
{
public:
A () {}
int size () { return box_.size (); }
void