假设我有这个 C++ 代码:
void exampleFunction () { // #1
cout << "The function I want to call." << endl;
}
class ExampleParent { // I have no control over this class
public:
void exampleFunction () { // #2
cout << "The function I do NOT want to call." << endl;
}
// other stuff
};
class ExampleChild : public ExampleParent {
public:
void myFunction () {
exampleFunction(); // how to get #1?
}
};
我必须从Parent
类继承才能自定义框架中的某些功能。但是,Parent
该类掩盖了exampleFunction
我要调用的全局。有什么方法可以调用它myFunction
吗?
(如果这有什么不同,我实际上在调用库中的time
函数时遇到了这个问题)<ctime>