我遇到的问题就像在标题"Effect" does not name a type
中所说的那样,所以我搜索了一下,然后发现了初始化,所以我在代码中添加了class Effect;
行,给出了另一个关于{的错误{1}},在搜索时我发现它是由于前方声明,所以现在我不知道该怎么办......
我认为问题是我有一个循环包含,这是文件:
field has incomplete type
#ifndef RUNE_HPP_INCLUDED
#define RUNE_HPP_INCLUDED
#include "Ressources.hpp"
#include "Effect.hpp"
class Effect; //Declaration of Effect
class Rune{
public:
Rune();
target getTarget();
effect getEffectName();
private:
Effect eff; //Error is here , with this code it is incomplete type
};
#endif // RUNE_HPP_INCLUDED
#ifndef EFFECT_HPP_INCLUDED
#define EFFECT_HPP_INCLUDED
#include "Ressources.hpp"
#include "Tile.hpp"
class Effect{ // Init of Effect
public:
Effect();
effect getName();
target getTarg();
void actionTile(Tile& tileTarget);
private:
effect name;
target targ;
};
#endif // EFFECT_HPP_INCLUDED
#ifndef TILE_HPP_INCLUDED
#define TILE_HPP_INCLUDED
#include "TileStatic.hpp"
#include "TileDynamic.hpp"
class Tile{
public:
private:
TileStatic staticTile;
TileDynamic dynamicTile;
};
#endif // TILE_HPP_INCLUDED
Ressources.hpp不包含项目文件,它只是常量和一些结构。他们在这里:
#ifndef TILEDYNAMIC_HPP_INCLUDED
#define TILEDYNAMIC_HPP_INCLUDED
#include "Trap.hpp"
#include "Rune.hpp"
class TileDynamic{
public:
private:
Rune rune;
Trap trap;
};
#endif // TILEDYNAMIC_HPP_INCLUDED
#endif // RESSOURCES_HPP_INCLUDED
我希望有人知道解决问题的方法,我认为这是一个包含问题。
答案 0 :(得分:-1)
每个函数的返回类型的首字母都是小写的,但是你的类名以highcase开头。我认为这就是问题所在。