【发布时间】:2017-10-13 04:11:51
【问题描述】:
好的,这就是我的错误:'Enemy' 未在此范围内声明。错误出现在 map.h 文件中,即使 map.h 包含如图所示的敌人.h
#ifndef MAP_H_INCLUDED
#define MAP_H_INCLUDED
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include "enemy.h"
#define MAX_TILE_TYPES 20
using namespace std;
class Map{
public:
Map();
void loadFile(string filename);
int** tile;
int** ftile;
bool solid[MAX_TILE_TYPES];
int width;
int height;
int tileSize;
vector<Enemy> enemies;
};
#endif // MAP_H_INCLUDED
这里是敌人.h
#ifndef ENEMY_H_INCLUDED
#define ENEMY_H_INCLUDED
#include "global.h"
#include "map.h"
class Enemy{
public:
Enemy();
Enemy(float nx, float ny, float nstate);
void update(Map lv);
bool rectangleIntersects(float rect1x, float rect1y, float rect1w, float rect1h, float rect2x, float rect2y, float rect2w, float rect2h);
void update();
float x;
float y;
Vector2f velo;
float speed;
float maxFallSpeed;
int state;
int frame;
int width;
int height;
int maxStates;
int *maxFrames;
int frameDelay;
bool facingLeft;
bool onGround;
bool dead;
int drawType;
};
#endif // ENEMY_H_INCLUDED
有人知道发生了什么以及如何解决吗?
【问题讨论】:
-
出现此错误时正在编译哪个源文件(.cpp、.c、.cc 等...)?它看起来像什么?
标签: c++ include circular-dependency