Virtual functions always and forever virtual?
I have a general question concerning virtual functions. I think in Qt almost all destructors are virtual. QObject has a virtual destructor. But QWidget has no destructor which is explicitly defined as virtual in qwidget.h.
- Is it necessary to define virtual functions of the base class also in my class as virtual?
- Is a virtual function always virtual in every inherited class or is it possible to remove the virtual property?
You should ask such questions here: http://forum.qt.io/category/34/c-gurus
since it is not related to Qt.
You can omit "virtual" keyword in derived classes. And it is not necessary to define inherited virtual methods in derived classes, you only do this if you need a different behaviour or if it is a pure virtual method and you're going to instantiate your class.
Methods (not functions) defined as virtual remain virtual.
Look at https://en.wikipedia.org/wiki/C%2B%2B11#Explicit_overrides_and_final if you are using C++11