title: Undefined symbols for architecture x86_64: "SingleInstance::sm"
body: <p>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:</p>
  
  <pre><code>#include &lt;iostream&gt;
  
  using namespace std;
  class SingleInstance {      
  public:
      static void getInstance()
      {
  
              sm = new SingleInstance();
              cout &lt;&lt;"build new instance" &lt;&lt; endl;
      }
  private:
              SingleInstance(){}
              ~SingleInstance(){}
              static SingleInstance* sm;
  
  };
  int main()
  {
         SingleInstance::getInstance();
         return 0;
  }
  </code></pre>