如何将具有相同名称的继承函数视为重载函数?

问题描述 投票:1回答:1

我在类A中创建了一个函数,而类A是B类的基类子对象。在B类中,我创建了一个具有相同名称和签名的函数,其中一个在类A中。在B类函数中,我想在类A中调用该函数但不会过载。我怎么用呢?

class Document{
public:
void Input(){};
};

class Book:public Document{
public:
void Input(){this->Input();} //I want to use Document's function here
};
c++ inheritance scope overloading
1个回答
1
投票

您可以使用基类名称显式引用它:

void Input(){Document::Input();}
© www.soinside.com 2019 - 2024. All rights reserved.