Thread: What does this mean?

  1. #1
    Its hard... But im here swgh's Avatar
    Join Date
    Apr 2005
    Location
    England
    Posts
    1,688

    What does this mean?

    I compiled my class function for my player and my compiler generated an error I don't get:


    ERROR: Unable to acsess member '*GameEngine' class declared 'protected'

    Here is the code:

    Code:
    Class Player
    {
    public:
    Player();      // constructor
    ~Player();   // deconstuctor
    void PlayerFunction ( void )
    
    private:
    int health;
    int age;
    
    protected:
    static GameEngine*	m_pGameEngine;   // pointer to GameEngine 
    
    };
    I would post more but there is over 13500 lines of code! lol

    Any help appriciated

  2. #2
    Crazy Fool Perspective's Avatar
    Join Date
    Jan 2003
    Location
    Canada
    Posts
    2,640
    m_pGameEngine is a protected variable. Only functions written in the Player class and derived classes can access that variable.

    At the risk of sounding offensive, how did you write over 13,000 lines of C++ code without knowing one of the most fundamental properties of C++ OOP?

  3. #3
    Its hard... But im here swgh's Avatar
    Join Date
    Apr 2005
    Location
    England
    Posts
    1,688
    Oh yes.. Whoops!!! LoL sorry I forgot that. It was a bit annoying cause the rest of my code was ok, Thanks prospective much apprecicated! I was pretty tired when i wrote that class, I know how to alter it.

  4. #4
    S Sang-drax's Avatar
    Join Date
    May 2002
    Location
    Göteborg, Sweden
    Posts
    2,072
    Quote Originally Posted by swgh
    It was a bit annoying cause the rest of my code was ok,
    Hmmm.. You spelled 'Class' with a capital C and you forgot a semicolon after the member function.
    Last edited by Sang-drax : Tomorrow at 02:21 AM. Reason: Time travelling

  5. #5
    Its hard... But im here swgh's Avatar
    Join Date
    Apr 2005
    Location
    England
    Posts
    1,688
    class player was in a sperarate header file, I did not cut and paste the code above I copied it out from the editor.. These two errors are not in the actual program.. I say this in my defense!! lol

Popular pages Recent additions subscribe to a feed