Pointer to another classs as a property

Posted by arjacsoh on Stack Overflow See other posts from Stack Overflow or by arjacsoh
Published on 2011-11-26T09:37:59Z Indexed on 2011/11/26 9:53 UTC
Read the original article Hit count: 185

Filed under:
|
|

Why I receive an error when I try to create a property to another class through a pointer like that:

#ifndef SQUARE_H
#define SQUARE_H

#include <string>
//using namespace std;

    #include "Player.h"

class Square

{
public:

    Square(int); 
    void process();

protected:

    int ID;
    Player* PlayerOn;          <---

};



    #endif

and the Player class is :

    #ifndef PLAYER_H
    #define PLAYER_H

    #include <string>
//using namespace std;

    #include "Square.h"

class Player
{
public:

    Player(int,int);
//  ~Player(void);
    int playDice();


private:

        int ID;
        int money;


};
#endif

I receive:

syntax error missing ; before * (on the declaration of  Player* PlayerOn;)

and missing type specifier (on the same line...)

© Stack Overflow or respective owner

Related posts about c++

Related posts about pointers