我的编译器说:

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...]
};

谁能告诉我问题是什么?

如果您需要更多代码,请发表评论,我将其发布。但是整个过程相当大,因此我现在并未包括在内。

最佳答案

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

class UberMaterial : public BaseMaterial
{
    ...

public:
    using BaseMaterial::Initialize;

    virtual void Initialize(ContentManager *pContentManager);
};

10-04 11:04