[C++]Using Heading Guards But Still An Identifier Error

Wanting both cPlayer and cSquare to be able to know about each other but I do not want both includes to mess each other up. I have *learnt* about heading guarders however I still receive a

> syntax error: identifier cPlayer

This is problematic as I plan on including a cSquare vector in cPlayer which is why I would like them both know about each other. Could someone enlighten me in this situation?

http://pastebin.com/YVz9w3GZ
> including a cSquare vector in cPlayer
> which is why I would like them both know about each other.
¿why should `cSquare' know anything about `cPlayer'?


For a vector, a forward declaration should suffice.
Because the vector is going to be a pointer type of cSquare.

example: vector<cSquare*> vOwnedProperties;

So I assume cPlayer must need to know about cSquare in order to know how to deal with it even though they are only going to be an address of pointers.

The problem is They both need to include each other
It's just a pointer so the compiler only needs to know that cSquare is a class, so a forward declaration of cSquare should be enough in the header. In the source file, where you actually use the cSquare class, you probably need to include the cSquare header file but that is not a problem.
Topic archived. No new replies allowed.