What is "error C2061: syntax error : identifier "?

That's a pretty common mistake - you have circular include dependency.

Looking at your code, you should replace #include "Player.h" with class Player; in Collision.h. This is called "forward declaration" and will break the circular dependency.


Also, it would be good to add include guards, for example:

#ifndef MY_PLAYER_CLASS
#define MY_PLAYER_CLASS

...

#endif

And this should be done for each header you write.


Circular dependency or you're using a C compiler for C++ code


You have a circular include dependency. Collision.h includes Player.h and vice versa. The simplest solution is to remove #include "Collision.h" from Player.h, since the Collision class is not needed in the Player declaration. Besides that, it looks like some of your includes in Collision.h can be replaced by forward declarations:

// forward declarations
class Player;
class Platform;

class Collision
{
public:
  Collision(void);
  ~Collision(void);
  static bool IsCollision(Player &player, Platform& platform);
};

You can then put the includes in Collision's implementation file.

Tags:

C++