dimanche 25 octobre 2020

Override function in source file

I'm building a cross platform application, and I have this:

// Gui.h
class View {
protected:
    virtual void doSomething();
};

class Window : public View {
public:
    void doSomethingElseUnrelated();
};

Now for each platform, I have my own Gui.cpp file. So there is one Gui.h file, and a Gui.cpp for each platform.

Now on the windows platform, I can just call the Window class function doSomething. However, on Mac platform, the implementation for Window class and View class doSomething is different.

So on Mac platform I have to override the doSomething function in the Window class.

That means I have to add the doSomething Window class override in the header file. This will then affect all platforms, even though it is only needed on Mac platform.

Is it possible to add the override of doSomething in the Window class only for Mac platform?

Aucun commentaire:

Enregistrer un commentaire