Возможный дубликат:
необъявленный идентификатор C++ (но заявлено?)
Я получаю сообщение об ошибке sprite.h(20): error C2065: 'Component' : undeclared identifier при попытке скомпилировать (у меня также есть пара других файлов). Ниже находится файл sprite.h. Я не могу в жизни понять, что вызывает эту проблему.
#ifndef SPRITE_H
#define SPRITE_H
#include "Image.h"
#include "Rectangle.h"
#include <string>
#include <SDL.h>
#include <vector>
#include "Component.h"
namespace GE2D {
class Sprite {
public:
Sprite();
Sprite(Image *i);
Sprite(Image *i, int x, int y);
Sprite(char *file, bool transparentBg, int x, int y, int w, int h);
virtual ~Sprite();
virtual void tick(SDL_Surface *screen, std::vector<Sprite*>* sprites, std::vector<Component*>* components);
virtual void handleEvent(SDL_Event eve);
virtual void draw(SDL_Surface *screen);
void setPosition(int x, int y);
const Rectangle& getRect() const;
const Image& getImage() const;
const Sprite& operator=(const Sprite& other);
Sprite(const Sprite& other);
protected:
private:
Image image;
Rectangle rect;
};
}
#endif
В файле .cpp tick() определяется так:
void Sprite::tick(SDL_Surface *screen, std::vector<Sprite*>* sprites, std::vector<Component*>* components) {}
Предполагается, что tick() принимает два вектора, как сейчас, но, может быть, есть лучший способ сделать это, который мог бы решить эту проблему?
EDIT В соответствии с просьбой, вот также Component.h:
#ifndef COMPONENT_H
#define COMPONENT_H
#include "Rectangle.h"
#include "Component.h"
#include "Sprite.h"
#include <vector>
#include <SDL.h>
namespace GE2D {
class Component {
public:
Component();
virtual ~Component();
virtual void draw(SDL_Surface *screen) = 0;
virtual void tick(SDL_Surface *screen, std::vector<Sprite*>* sprites, std::vector<Component*>* components) = 0;
virtual void handleEvent(SDL_Event eve) = 0;
const Rectangle& getRect() const;
protected:
Component(int x, int y, int w, int h);
private:
Rectangle rect;
};
}
#endif
Component.h- person Alok Save   schedule 28.12.2012