Why class declaration ordering still matters with prototyping?
问题 I was struggling with a 'field "player" has incomplete type" error with my code. My class "game_session" contains a single "player" and I declare them both in the same header file as shown below: #ifndef HEADER_H #define HEADER_H #include <iostream> #include <vector> using std::vector; class Player; class GameSession; class GameSession{ private: ... Player player; public: GameSession(); ~GameSession(); ... }; class Player { public: Player( int maxdim ); ~Player(); ... }; The above code would