title: Singleton Class in C++
body: <p>I have used singleton calss following the example:</p>
  
  <p><a href="https://stackoverflow.com/questions/3393403/singleton-class">singleton class</a></p>
  
  <p>But i get the error as <strong>"Unresolved external symbols"</strong></p>
  
  <p>this is the code i tried out:</p>
  
  <pre><code>#include&lt;iostream&gt;
  using namespace std;
  
  class singleton
  {
      int value;
      static singleton *instance;
  protected:
      singleton()
      {
          value=0;
      }
  public:
      static void initialize()
      {
          if(instance==NULL)
              singleton();
          else
              cout&lt;&lt;"An instance of singleton already exist...";
      }
      static singleton&amp; getInstance()
      { 
          return *instance; 
      }
      int getValue() 
      { 
          return value; 
      }
  
  };
  
  void main()
  {
      singleton::initialize();
  }
  </code></pre>
  
  <p><em>A little bit explanation on Singleton classes would be really great. The scenario its used. advantages and drawbacks. Alternatives to Singleton. etc</em></p>