继续尝试解析类不命名类型

时间:2014-10-18 14:04:47

标签: c++ class

我遇到的问题就像在标题"Effect" does not name a type中所说的那样,所以我搜索了一下,然后发现了初始化,所以我在代码中添加了class Effect;行,给出了另一个关于{的错误{1}},在搜索时我发现它是由于前方声明,所以现在我不知道该怎么办...... 我认为问题是我有一个循环包含,这是文件:

错误代码:

field has incomplete type

Effect.hpp:

#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

Tile.hpp

#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

TileDyanmic.hpp,循环循环:

#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

我希望有人知道解决问题的方法,我认为这是一个包含问题。

1 个答案:

答案 0 :(得分:-1)

每个函数的返回类型的首字母都是小写的,但是你的类名以highcase开头。我认为这就是问题所在。