   Inheritance private member acess
  I'm making an enemy class which is going to have many different enemy types but I have a problem. When I set the variables to their values in the Blob constructor the compilator complains about accessing private members in the enemy class. Is there any way to make the private members in the enemy class accessable without moving them to the public section?Example:class Enemy {  public:    Enemy();    virtual void show();  private:    int x,y;    int xVel, yVel;   SDL_Surface *enemies;    SDL_Rect enemyBox;};class Blob : public Enemy {  public:    Blob(int xPos, int yPos, string dir, int range);  private:    // attributes    int damage;    int hp;   int frame;   // variables used for the walking process    int walkDirection;    int walkRange;    int counter;};;   
  You can use protected instead of private, if derived classes should be able to access the members.   ;  I tried to make the private members of the enemy class to protected but it still result in errors. The errors that appears this time is different however, it's like the variables doesn't exist.example:main.cpp `direction' undeclared (first use this function)   ;Quote:Original post by passwordI tried to make the private members of the enemy class to protected but it still result in errors. The errors that appears this time is different however, it's like the variables doesn't exist.example:main.cpp `direction' undeclared (first use this function)There is no variable called direction in your code as posted. This is a different error, perhaps unrelated to private/protected. If you need help with this error, post more code.   ;Quote:Original post by rip-offThere is no variable called direction in your code as posted. This is a different error, perhaps unrelated to private/protected. If you need help with this error, post more code.That's true, my wrong, it's just that I forgot to make some variables. On top of that I also forgot to add the number of sdl_rects I used and used playerBox instead of enemyBox because I copied the player collision code into this code. That was really careless of me, thanks for your help anyways..   