title: Pointer set to null
body: <p>Code:</p>
  
  <pre><code>#include &lt;iostream&gt;
  class GlobalClass
  {
  
      static GlobalClass *s_instance;
  
    public:
      static GlobalClass *instance()
      {
          if (!s_instance)
            s_instance = new GlobalClass;
          return s_instance;
      }
      void SetPointer(void *ptr)
      {
          this-&gt;PointerSetter(ptr);
          std::cout &lt;&lt; "ptr:" &lt;&lt; ptr &lt;&lt; std::endl;
      }
      void PointerSetter(void *ptr)
      {
          int Value = 1;
          ptr = &amp;Value; 
          std::cout &lt;&lt; "ptr:" &lt;&lt; ptr &lt;&lt; std::endl;
      }
  };
  
  GlobalClass *GlobalClass::s_instance = 0;
  
  int main()
  {
     void *ptr=NULL;
     std::cout &lt;&lt; "ptr:" &lt;&lt; ptr &lt;&lt; std::endl;
     GlobalClass::instance()-&gt;SetPointer(ptr);
     std::cout &lt;&lt; "ptr:" &lt;&lt; ptr &lt;&lt; std::endl;
     return 0;
  }
  </code></pre>
  
  <p>Output:</p>
  
  <pre><code>ptr:0
  ptr:0x6ffddc
  ptr:0
  ptr:0
  </code></pre>
  
  <p>I am not able to understand why the pointer that I passed to function <code>SetPointer</code> in the singleton instance of <code>GlobalClass</code> which in turn is passed to <code>PointerSetter</code> is not visible when it comes out of <code>PointerSetter</code>. I need to access it in my <code>main</code> function. 
  How is the pointer is being set to NULL or 0? </p>