继续尝试解析类不命名类型
Keep tryning to resolve a class Does not name a Type
我遇到的问题就像标题中说的"Effect" does not name a type
,所以我搜索并找到了关于去操作,然后是初始化,所以我在代码中添加了一行class Effect;
,给出了关于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
Tile.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
TileDyanmic.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
Ressources.hpp不包括项目文件,它只是常量和一些结构。它们在这里:
#ifndef RESSOURCES_HPP_INCLUDED
#define RESSOURCES_HPP_INCLUDED
#include <SFML/Graphics.hpp>
#include <SFML/Window.hpp>
#include <SFML/System.hpp>
enum effect{
ZERO_EFFECT,
INST_DAMAGE,
POISON,
SLOW,
STUN,
SILENCE,
HEAL
};
enum target{
ZERO_TARGET,
SELF,
ENEMY,
TILE
};
sf::Texture getNoTexture();
const sf::Texture NO_TEXTURE = getNoTexture();
struct coord{
int x;
int y;
};
coord getZeroCoord();
const coord ZERO_COORD = getZeroCoord();
#endif//RESSOURCE_HPP_INCLUDED
我希望任何人都知道解决我的问题的方法,我认为这是一个包容性问题。
每个函数的返回类型的首字母都是小写,但类名以大写开头。我认为这就是问题所在。
相关文章:
- ArduinoJson 6.15.2:JsonObject没有命名类型
- 防止主数据类型C++的隐式转换
- 大量序列中核苷酸类型的快速计数
- 如何从C++中的依赖类型中获得它所依赖的类型
- 有关插入适配器的错误。[错误]请求从 'back_insert_iterator<vector<>>' 类型转换为非标量类型
- 是否可以初始化不可复制类型的成员变量(或基类)
- 如何获取std::result_of函数的返回类型
- 从父命名空间重载类型
- 如果C++类在类方法中具有动态分配,但没有构造函数/析构函数或任何非静态成员,那么它仍然是POD类型吗
- 我想将一个对T类型的非常量左值引用绑定到一个T类型的临时值
- Openssl 1.1.1d无效使用不完整的类型"struct dsa_st"
- 访问者访问变体并返回不同类型时出错
- 循环后如何继续阅读
- 在VS2010-VS2015下编译时,如何使用decltype作为较大类型表达式的LHS
- 处理小于cpu数据总线的数据类型.(c++转换为机器代码)
- C++继续获取表达式必须具有类类型
- 模板专用化中的类型将继续计算?
- 如何在无效的数据类型输入后继续循环
- 继续尝试解析类不命名类型
- 当cin不是int类型时,c++程序继续循环