title: Static Classes with C++
body: <p>Let me start by saying, I understand that "Static Classes" are not something that are used in C++, but I have a situation which I believe all information held by the class should be static. I am trying to understand if there is a better way to approach my problem.</p>
  
  <p><strong>Example</strong>: I am building a class to maintain information on my game's <code>window</code>, so I can access the current <code>window</code>'s <code>width</code> and <code>height</code> from any instance of the object. This class will be edited when I resize, minimize, maximize etc. My video game will never have two separate windows, only separate instances which should all contain the same data. Here is what I have:</p>
  
  <hr>
  
  <p><strong>Window.h</strong></p>
  
  <pre><code>class Window {
      static int width;
      static int height;
  public:
      Window();
      Window(int width, int height);
      static int getWindowWidth();
      static int getWindowHeight(); 
  }
  </code></pre>
  
  <p><strong>Window.cpp</strong></p>
  
  <pre><code>#include "Window.h"
  
  int Window::width = 0;    
  int Window::height = 0;
  
  Window::Window( ) { }
  
  Window::Window(int window_width, int window_height) {
  
      width = window_width;        
      height = window_height;
  
      SDL_CreateWindow( "Window",
                         SDL_WINDOWPOS_UNDEFINED,
                         SDL_WINDOWPOS_UNDEFINED,
                         width,
                         height,
                         SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE | SDL_WINDOW_SHOWN
                      );
  }
  
  int getWindowWidth() {
      return width;
  }
  
  int getWindowHeight() {
      return height;
  }
  </code></pre>
  
  <p><br><hr></p>
  
  <p>Using this method I am able to retrieve the <code>window</code>'s <code>width</code> as well as its <code>height</code> from any instance of the object. </p>
  
  <p>However, it doesn't feel correct ( or elegant) because using this method, I now have to list every variable as <code>static</code> and each of these variable have to be initiated outside <code>Constructors</code> in my <code>.cpp</code> code ( and because your not supposed to have static classes in C++ ).</p>
  
  <p>How can I access the <code>window</code>'s information from multiple instances without creating a static class?</p>
  
  <p><br></p>
  
  <p><em>Thanks In Advance</em></p>