title: c++ access violation writing location
body: <p>I am new to c++, and i have difficulties understannding some of it's parts, especially in memory management. This is one of my first projects, an SFML lib game. So i get an access violation error, in this code:</p>
  <h1>include &quot;Game.h&quot;</h1>
  <pre><code>void Game::Start()
  {
      if (_gameState == Uninitialized)
          return;
      _mainWindow.create(sf::VideoMode(1024, 768, 32), &quot;Hi!&quot;);
      _gameState = Game::Playing;
  
      while (!IsExiting()){
          GameLoop();
      }
  
      _mainWindow.close();
  }
  
  bool Game::IsExiting(){
      if (_gameState == Game::Exiting)
      {
          return true;
      }
      else 
      {
          return false;
      }
  }
  
  void Game::GameLoop(){
      sf::Event currentEvent;
      while (_mainWindow.pollEvent(currentEvent))
          {
              switch (_gameState)
              {
              case Game::Playing:
                  {
                      _mainWindow.clear(sf::Color(255, 255, 255));
                      _mainWindow.display();
  
                      if (currentEvent.type == sf::Event::Closed)
                      {
                          _gameState = Game::Exiting;
                      }
                      break;
                  }
              }
          }
  }
  
  Game::GameState Game::_gameState = Uninitialized;
  sf::RenderWindow Game::_mainWindow;
  </code></pre>
  <p>The error happens, when code gets to the very last line of code, the _mainWIndow declaration. I understand, that problem most probably happened because i do not completely understand the quirks of static. But i still dont yet understand what causes the problem, and how to solve it.</p>
  <p>The Game class:</p>
  <pre><code>class Game
  {
  public:
      static void Start();
  private:
      static bool IsExiting();
      static void GameLoop();
  
      enum GameState {Uninitialized, ShowingSplash, Paused, ShowingMenu, Playing, Exiting};
  
      static GameState _gameState;
      static sf::RenderWindow _mainWindow;
  };
  </code></pre>