Ошибка -неверное использование неполного типа/упреждающего объявления

Моя проблема довольно распространена, я знаю, но я искал и пробовал все решения, которые я нашел, и все еще не работает. Так что любая помощь будет принята с благодарностью! =)

Заранее спасибо!

У меня эта ошибка при компиляции:

g++ -ISFML/include -Iclasses/ -W -Wall -Werror   -c -o classes/Object.o classes/Object.cpp
In file included from classes/Core.hh:18:0,
         from classes/Object.hh:4,
         from classes/Object.cpp:1:
classes/MapLink.hh:9:1: error: invalid use of incomplete type ‘struct Object’
classes/MapLink.hh:6:7: error: forward declaration of ‘struct Object’
In file included from classes/Core.hh:19:0,
         from classes/Object.hh:4,
         from classes/Object.cpp:1:
classes/Player.hh:9:1: error: invalid use of incomplete type ‘struct Object’
classes/MapLink.hh:6:7: error: forward declaration of ‘struct Object’
make: *** [classes/Object.o] Error 1

В общем, у меня есть файл main, содержащий (main.cpp)

#include "Core.hh"

int        main(void)
{
 ...
}

Вот заголовочный файл, содержащий все мои включения (Core.hh)

#ifndef __CORE_HH__
# define __CORE_HH__

#include...
#include "Object.hh"
#include "MapLink.hh"
#include "Player.hh"

class Core
{
 ...
};

#endif /* __CORE_HH__ */

А потом файлы, которые вызывают у меня проблемы (Object.hh)

#ifndef __OBJECT_HH__
# define __OBJECT_HH__

#include "Core.hh"

class Object
{
 ...
};

#endif /* __OBJECT_HH__ */

(MapLink.hh)

#ifndef __MAPLINK_H__
# define __MAPLINK_H__

#include "Core.hh"

class Object;

class MapLink : public Object
{
 ...
};

#endif /* __MAPLINK_H__ */

(Player.hh)

#ifndef __PLAYER_H__
# define __PLAYER_H__

#include "Core.hh"

class Object;

class Player : public Object
{
 ...
};

#endif /* __PLAYER_H__ */
19
задан Guillaume Jacquenot 16 June 2017 в 13:05
поделиться