Y
ying.gary.zhang
// T.h:
class T
{
public:
static T* instance();
private:
T() {}
~T() {}
static T* smInstance;
};
// T.cpp:
T* T::instance()
{
if (smInstance == NULL)
smInstance = new T();
return smInstance;
}
when I try to compile the above code, there is linker error:
.../T.cpp:3: undefined reference to `T::smInstance`
I am using gcc 3.4.6 under gentoo linux, thanks
class T
{
public:
static T* instance();
private:
T() {}
~T() {}
static T* smInstance;
};
// T.cpp:
T* T::instance()
{
if (smInstance == NULL)
smInstance = new T();
return smInstance;
}
when I try to compile the above code, there is linker error:
.../T.cpp:3: undefined reference to `T::smInstance`
I am using gcc 3.4.6 under gentoo linux, thanks