I define a static member in a class, but i can't assign static member in static function. ERROR: "Undefined symbols for architecture x86_64: "SingleInstance::sm". This is my c++ code:
#include <iostream>
using namespace std;
class SingleInstance {
public:
static void getInstance()
{
sm = new SingleInstance();
cout <<"build new instance" << endl;
}
private:
SingleInstance(){}
~SingleInstance(){}
static SingleInstance* sm;
};
int main()
{
SingleInstance::getInstance();
return 0;
}