小编Jac*_*koz的帖子

错误"未在范围中声明"但带有接口

你看,我一直在尝试创建一个std::vector包含Entity类中类的IState类.这两个类都是接口.

错误是

"实体"未在此范围内声明

并指出:

protected:
    std::vector <Entity*> ent_map;
Run Code Online (Sandbox Code Playgroud)

在IState.h中

我一直在努力解决它.一旦我在IState.h中做了一个前向声明,但是一旦我做了并尝试使用向量,它就会发出它是一个不完整的类,所以我回到原点.

有任何想法吗?

Entity.h

#ifdef __ENTITY__
#define __ENTITY__

#include <iostream>
#include <SDL.h>

class Entity
{
    public:
    virtual ~Entity();
    virtual void load(const char* fileName, std::string id, SDL_Renderer* pRenderer) = 0;
    virtual void draw() = 0;
    virtual void update() = 0 ;
    virtual void clean() = 0;

    /*void int getX() { return m_x;}
    void int getY() { return m_y;}
    void std::string getTexID {return textureID;}
    */


};


#endif // …
Run Code Online (Sandbox Code Playgroud)

c++ macros include-guards

3
推荐指数
1
解决办法
451
查看次数

标签 统计

c++ ×1

include-guards ×1

macros ×1