C++ Why Is There “Unknown Type” When Class Header is Included?

If you include Item.h from your cpp file, Player.h is included from it. Then, Player.h includes Item.h again, but thanks to the include guard, this does virtually nothing.

Then, in the included Player.h, no Item is declared yet. Therefore, the compiler will emit the error.

Since nothing from Player.h is used in Item.h, remove #include "Player.h" from Item.h.

Leave a Comment