title: Singleton Implementation in C++
body: <p>I'm trying to implement a singleton in C++. I'm fairly new to the language so please explain if I made any trivial error.</p>
  
  <p>Below is my Header File:</p>
  
  <pre><code>#pragma once
  #include &lt;glad\glad.h&gt;
  #include &lt;GLFW\glfw3.h&gt;
  #include "Imgui\imgui.h"
  #include "imgui_impl_glfw_gl3.h"
  
  
  class GUI
  {
  
      static GUI * instance;
  
  private:
  
      GUI();
  
  public:
  
      static GUI * Instance();
  
      void Init(GLFWwindow * window);
      void Loop();
      void Draw();
      void End();
  
      ~GUI();
  };
  </code></pre>
  
  <p>And part of the Class file.</p>
  
  <pre><code>GUI::GUI()
  {
      instance = nullptr;
      // static GUI * instance = nullptr;
  }
  
  
  GUI * GUI::Instance()
  {
      if (nullptr == instance) {
          instance = new GUI();
      }
  
      return instance;
  }
  </code></pre>
  
  <p>I feel like it should work, however, I'm getting this error when I try to execute.</p>
  
  <p><a href="https://i.stack.imgur.com/bayKp.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/bayKp.png" alt="Error Image."></a></p>
  
  <p>I am fairly new to this, so any help as to why I am erroring out would be appreciated. </p>