title: Class already exists
body: <p>In my project I am having 2 classes: 'Window' and 'Context'.
  The class 'Window' instantiates a Window using WinAPI and everything works fine.
  E.g. this code works as supposed:</p>
  
  <pre><code>Window win("Hello,", 600, 400);
  Window win2("World!", 600, 400);
  </code></pre>
  
  <p>The class 'Context' creates an OpenGL 4.0 Context. In order to do so, 
  it needs to create a temporary window and a temporary context to retreive all OpenGL 4.0 pointer, which in return are needed to create a OpenGL 4.0 context.
  E.g. this code works as well:</p>
  
  <pre><code>Window win("Context", 600, 400);
  Context ctx(win);
  </code></pre>
  
  <p>Everything works fine.</p>
  
  <p>However, I am refactoring the code. Since a window can have only one context at all, I decided, that the window should manage the context, therefore it should instantiate and delete it itself. But this leads me to strange errors.</p>
  
  <pre><code>// Constructor of window
  // We're at the end of the constructor
  if(true == bOWnContext)
      pContext = internal::Context(*this);
  }; // Constructor ends here
  </code></pre>
  
  <p>When executing the application I get an exception/error: "Class already registered."
  This is strange since following code works for me:</p>
  
  <pre><code>Window winA(...);
  Window winB(...);
  // or
  Context ctx(winA);
  // This works like a charm
  </code></pre>
  
  <p>Some collegue suggested, I should register the window class only once,
  so I tried the following in the constructor:</p>
  
  <pre><code>    static bool bRegistered = false;
      if(false == bRegistered){
      WNDCLASSEX  wc      = {};
      wc.cbSize           = sizeof(WNDCLASSEX);
      wc.hInstance        = GetModuleHandle(nullptr);
      wc.lpfnWndProc      = internal::WndProc;
      wc.lpszClassName    = pTitle;
      wc.style            = CS_VREDRAW | CS_HREDRAW | CS_OWNDC;
  
      if(0 == RegisterClassEx(&amp;wc)){
          //
          //  The exception class will contain the error code and
          //  a error discription.
          //
          std::error_code err_code(GetLastError(), std::system_category());
          throw std::system_error(err_code);
      }
      bRegistered = true;
      }
  </code></pre>
  
  <p>However, this gives me another error "Cannot find window class."</p>
  
  <p>Can somebody enlighten me, why my code is not working?</p>