How can I call a masked function in C++?

c++, inheritance, masking

Solution

Do the following:

::exampleFunction()

`::` will access the global namespace.

If you `#include <ctime>`, you should be able to access it in the namespace `std`:

std::time(0);

To avoid these problems, place everything in namespaces, and avoid global `using namespace` directives.

Problem

Let's say I have this C++ code: ``` 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? } }; ``` I have to inherit from the `Parent` class in order to customize some functionality in a framework. However, the `Parent` class is masking the global `exampleFunction` that I want to call. Is there any way I can call it from `myFunction`? (I actually have this problem with calling the `time` function in the `<ctime>` library if that makes any difference)

Original source