The C++ Programming Language by Bjarne Stroustrup (p. 392, 2nd ed.): 15.2.2继承和使用声明 重载解析不适用于不同的类范围(第7.4节)…… 15.2.2 Inheritance and Using-Declarations Overload resolution is not applied across different class scopes (§7.4) …您可以使用限定名称访问它:You can access it with a qualified name:void SomeOtherFunction(){ SubClass* test = new SubClass(); test->Base::Data(1, 1);}或通过在 SubClass 中添加using-声明:or by adding a using-declaration to SubClass:class SubClass : public Base{ public: using Base::Data; virtual CString& Data( UINT index);};void SomeOtherFunction(){ SubClass* test = new SubClass(); test->Data(1, 1);} 这篇关于为什么我不能使用子类的指针访问基类的公共函数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
09-11 10:17