I have the following piece of code .
class base {
private:
static base *b_h;
public:
static base* getInstance() {
if(!b_h) {
b_h = new base();
}
return b_h;
}
};
int main()
{
base* b;
b = base::getInstance();
return 0;
}
When i try to compile, I am facing the below error :
main.cpp:(.text._ZN4base11getInstanceEv[_ZN4base11getInstanceEv]+0x15): undefined reference to base::b_h' /usr/bin/ld: main.cpp:(.text._ZN4base11getInstanceEv[_ZN4base11getInstanceEv]+0x1c): undefined reference to
base::b_h'
Can someone please help me on this ?