This shows you the differences between two versions of the page.
Both sides previous revision Previous revision | |||
coding_guidelines [2019/09/27 18:15] daschuer [override / final] |
coding_guidelines [2019/09/27 18:18] (current) daschuer [override / final] |
||
---|---|---|---|
Line 597: | Line 597: | ||
In contrast to the pre-C++11 rules (see above) when using //override// on a function in a derived class it is recommended to omit the redundant //virtual// keyword, because //override// implies //virtual//. | In contrast to the pre-C++11 rules (see above) when using //override// on a function in a derived class it is recommended to omit the redundant //virtual// keyword, because //override// implies //virtual//. | ||
- | Destructors in derived classes should also be marked with //override// instead of //virtual//. This ensures at compile time that the base class has declared a //virtual// destructor. If the base class has not declared a //virtual// destructor the destructor of a derived class might not be invoked. This applies also for default destructors ~destructor override = default;" even if it looks noisy. | + | Destructors in derived classes should also be marked with //override// instead of //virtual//. This ensures at compile time that the base class has declared a //virtual// destructor. If the base class has not declared a //virtual// destructor the destructor of a derived class might not be invoked. This applies also for default destructors even if it looks noisy. |
+ | <code cpp-qt> | ||
+ | ~ClassName() override = default; | ||
+ | </code> | ||
==== alignment ==== | ==== alignment ==== | ||