public inherited class无法访问基类的重载非虚公共方法?

时间:2011-12-29 00:20:54

标签: c++ inheritance overloading

我的编译器说:

error C2660: 'UberMaterial::Initialize' : function does not take 2 arguments

当我写这篇文章时:

#include "BaseMaterial.h"
#include "UberMaterial.h"

UberMaterial* m_pGameLevelMaterial;
m_pGameLevelMaterial->Initialize(m_pContentManager, m_pLevel->GetDevice());

基类:

class BaseMaterial
{
public:
BaseMaterial(tstring shaderFilename);
virtual ~BaseMaterial(){}

void Initialize(ContentManager *pContentManager, ID3D10Device *pD3DDevice);
//[More Code...]

protected:
    virtual void Initialize(ContentManager *pContentManager) = 0;
//[More Code...]
};

继承的课程:

#include "BaseMaterial.h"
class UberMaterial:public BaseMaterial
{
//[More Code...]
protected:
    virtual void Initialize(ContentManager *pContentManager);
//[More Code...]
};

谁能告诉我这是什么问题?

如果您需要更多代码,请发表评论,我会发布。但是整个事情相当大,所以此时我没有把它包括在内。

1 个答案:

答案 0 :(得分:4)

是的,默认情况下,派生类中的重载将隐藏与基类不同的重载。您可以使用using

重新公开基类重载
class UberMaterial : public BaseMaterial
{
    ...

public:
    using BaseMaterial::Initialize;

    virtual void Initialize(ContentManager *pContentManager);
};