title: How is this private variable "not declared in this scope"?
body: <p>I'm currently trying to learn more about object oriented design in C++ (familiar with Java) and am running into some walls. The project I am trying to put together to learn these principles in a game built using SFML for the graphics and audio. I have the following two files.</p>
  
  <p><strong>WorldObject.h</strong></p>
  
  <pre><code>#ifndef WORLDOBJECT_H
  #define WORLDOBJECT_H
  #include &lt;SFML/Graphics.hpp&gt;
  #include &lt;string&gt;
  #include "ImageManager.h"
  
  class WorldObject
  {
   private:
    sf::Sprite _sprite;
    void SetImagePath(std::string path);
    sf::Sprite GetGraphic();
  };
  #endif
  </code></pre>
  
  <p><strong>WorldObject.cpp</strong></p>
  
  <pre><code>#include "WorldObject.h"
  void WorldObject::SetImagePath(std::string path)
  {
    _sprite.SetImage(*gImageManager.getResource(path));
  }
  
  sf::Sprite GetGraphic()
  {
    return _sprite;
  }
  </code></pre>
  
  <p>I don't see any problem with either of these, and yet when I attempt to compile them I receive the following error from g++:</p>
  
  <pre><code>WorldObject.cpp: In function ‘sf::Sprite GetGraphic()’:
  WorldObject.cpp:9: error: ‘_sprite’ was not declared in this scope
  make: *** [WorldObject.o] Error 1
  </code></pre>
  
  <p>What am I missing in this code? Trying to understand the proper way to setup the inheritance hierarchy has been causing the most problems thus far in the game's development, but I know that that is primarily caused by the fact that I am more conditioned to using Java's inheritance model as opposed to C++'s multiple inheritance model.</p>