【发布时间】:2013-08-19 23:59:09
【问题描述】:
我在编译我正在为教育目的开发的小游戏时遇到未声明的标识符错误,我无法让全世界了解它的原因和来源。非常感谢任何帮助。
为什么我的“激光头”文件中的以下行会生成未声明的标识符错误 C2065?
bool hit(std::vector<Alien*> aliens);
这是完整的头文件:
#ifndef LASER_HPP_
#define LASER_HPP_
#include "Ship.h"
#include "Alien.h"
#include "Vector.h"
class Laser : public Sprite {
private :
bool armed;
int reloadTime, width, height, radius;
std::vector<Vector> bullets;
bool circleCollision(int x, int y, Ship* ship);
void reload();
public:
enum Type {
RED,
BLUE
};
Laser(Type type);
bool hit(std::vector<Alien*> aliens);
bool hit(Ship* ship);
void shoot(int x, int y, int dy);
void update();
void draw();
};
#endif LASER_HPP_
还有外星人的头文件:
#ifndef ALIEN_HPP_
#define ALIEN_HPP_
#include "Laser.h"
#include "Ship.h"
class Alien : public Ship {
private:
int nextX, laserSpeed, shotDelay;
bool attacking;
time_t lastShot;
bool targetReached();
bool timeToShoot();
bool enteringStage();
void shoot();
void move();
void init();
public:
Alien();
Alien(const char* filename);
Laser* laser;
void setNextTarget();
void update();
void attack();
void die();
};
#endif ALIEN_HPP_
我正在使用 VisualStudio 2012:S
错误:
error C2065: 'Alien' : undeclared identifier
【问题讨论】:
-
究竟什么是未定义的,哪个符号?
-
对不起,刚刚意识到。现在添加信息。第 25 行是包含列在顶部的第一个“命中”函数的行。
标签: c++ winapi header-files