Incomplete type cannot be defined

  Kiến thức lập trình

I am attempting to set up some header files for a game, however, attempting to set up variables in my main file’s header file causes an incomplete type error.

Both types have full definitions in their own .cpp files, but the .hpp files have the error.

#include "Map.hpp"
#include <iostream>

class Player;

int map;
MapData mapdata;
Player player;

The lines

MapData mapdata;
Player player;

say _____ has incomplete type and cannot be defined

(relevant line of Map.hpp):
class MapData;

Theme wordpress giá rẻ Theme wordpress giá rẻ Thiết kế website

LEAVE A COMMENT