title: pointer and non-pointer instance in C++ singleton
body: <p>I was practicing how to make a singleton.
  Everything was going just fine until I decided to play with it.
  the working version is:</p>
  
  <p>sing.hp:</p>
  
  <pre><code>class GlobalClass
  {
  private:
      GlobalClass(int);
      int m_value;
      static GlobalClass *s_instance;
  //    static GlobalClass instance;
    public:
  
      int get_value();
      void set_value(int v);
      static GlobalClass *GetS_instance();
  //    static GlobalClass GetInstance();
  };
  </code></pre>
  
  <p>sing.cpp</p>
  
  <pre><code>#include"sing.hpp"
  #include&lt;iostream&gt;
  using namespace std;
  
  GlobalClass * GlobalClass::s_instance = 0;
  //GlobalClass  GlobalClass::instance;
  
  GlobalClass::GlobalClass(int v = 10)
  {
      this-&gt;m_value = v;
  
  }
  
  int GlobalClass::get_value()
  {
      return this-&gt;m_value;
  }
  
  void GlobalClass::set_value(int v)
  {
      this-&gt;m_value = v;
  }
  
  GlobalClass * GlobalClass::GetS_instance()
  {
      if (!s_instance)
      {
          s_instance = new GlobalClass;
      }
      return s_instance;
  }
  
  //GlobalClass  GlobalClass::GetInstance()
  //{
  //
  //    return instance;
  //}
  </code></pre>
  
  <p>main.cpp:</p>
  
  <pre><code>#include "sing.hpp"
  #include&lt;iostream&gt;
  using namespace std;
  
  void foo(void)
  {
    GlobalClass::GetS_instance()-&gt;set_value(1);
    cout &lt;&lt; "foo: global_ptr is " &lt;&lt; GlobalClass::GetS_instance()-&gt;get_value() &lt;&lt; '\n';
  }
  
  int main()
  {
      cout &lt;&lt; "main: global_ptr is " &lt;&lt; GlobalClass::GetS_instance()-&gt;get_value() &lt;&lt; '\n';
        foo();
        return 1;
  }
  </code></pre>
  
  <p>The above set up works well until I uncomment what I have commented:
  I get the following error:</p>
  
  <pre><code>~/workspace/singleton2$ g++ *.cpp -o dr
  sing.cpp:6:27: error: no matching function for call to ‘GlobalClass::GlobalClass()’
  sing.cpp:6:27: note: candidates are:
  sing.hpp:5:2: note: GlobalClass::GlobalClass(int)
  sing.hpp:5:2: note:   candidate expects 1 argument, 0 provided
  sing.hpp:2:7: note: GlobalClass::GlobalClass(const GlobalClass&amp;)
  sing.hpp:2:7: note:   candidate expects 1 argument, 0 provided
  </code></pre>
  
  <p>Apart from not knowing why this occurred, the strange thing is that: the first line of error message points to line 6 in my program where I have defined the instance, while the error is indicating a mistake in my constructor. 
  could you please help me how to solve this issue?
  thank you all</p>