具有虚拟基类的可变参数类方法

时间:2019-06-04 10:05:33

标签: c++ c++11 entity-component-system

我试图将组件池生成器更改为使用可变参数模板,以避免所有Init()函数,而是使用每个组件构造函数。但是我无法使其编译。

这是组件池类:它有一个基类,其方法将被父类覆盖:

class iComponentPool
{

public:

    virtual iComponent* Create(EntityId entityId) = 0;
    virtual iComponent* Get(EntityId entityId) = 0;
    virtual void Destroy(EntityId entityId) = 0;
};

template<typename T>
class componentIterator
{

public:

    typename std::vector<T>::iterator beginIT;
    typename std::vector<T>::iterator endIT;

};

template<typename T, typename ... Targs>
class componentPool : public iComponentPool, public componentIterator<T>
{

public:

    T* Create(EntityId entityID, Targs... Args) override
    {

    };

    T* Get(EntityId entityId) override 
    { 
        return nullptr;
    };

    void Destroy(EntityId entityId) override 
    {

    };
};

但是,编译器抱怨(并且理所当然地)componentPool Create方法没有覆盖基类方法。有什么办法可以解决这个问题?

实际错误(VS 2015)为: ECS :: componentPool :: Create':带有覆盖说明符'override'的方法未覆盖任何基类方法。

0 个答案:

没有答案
相关问题