I really like the override keyword and have been burnt by adding const to methods/parameters and causing hiding issues. Things have gotten much better with that being enforced better in cppcheck and various functions getting flagged as missing overrides.
The CLANG compiler has a good warning for inconsistent use of override and by adding override to destructors that check gets triggered and helps point out other missing overrides.
To go along with your override improvements, flag destructors to help CLANG and others find missing overrides too. I would make this a destructorMissingOverride style or something like that so it can be suppressed if not wanted.
The other benefit of adding override to destructors is that if someone takes virtual off the base then it will cause a compile error vs. unexpected lack of the derived destructor being called.
I am not sure. If we add a warning about something stylistic I would like if that was considered "best practice". I saw that there is different opinions about this.
maybe this is something that would fit better in a addon.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I really like the override keyword and have been burnt by adding const to methods/parameters and causing hiding issues. Things have gotten much better with that being enforced better in cppcheck and various functions getting flagged as missing overrides.
The CLANG compiler has a good warning for inconsistent use of override and by adding override to destructors that check gets triggered and helps point out other missing overrides.
To go along with your override improvements, flag destructors to help CLANG and others find missing overrides too. I would make this a destructorMissingOverride style or something like that so it can be suppressed if not wanted.
The other benefit of adding override to destructors is that if someone takes virtual off the base then it will cause a compile error vs. unexpected lack of the derived destructor being called.
In derived classes I often change
virtual ~ExampleClass();
to
~ExampleClass() override;
which can also be combined with default if needed
~ExampleClass() override = default;
partially based on this long article override on virtual destructors
I am not sure. If we add a warning about something stylistic I would like if that was considered "best practice". I saw that there is different opinions about this.
maybe this is something that would fit better in a addon.