[Ovmsdev] Using the override keyword

Michael Geddes frog at bunyip.wheelycreek.net
Sat Jun 17 09:50:10 HKT 2023


Hi all,

So at my work, the main language I use is Delphi  (so Object Pascal), and
one of the things about Delphi is that you are forced to always be explicit
about overriding virtual methods. (Missing out on 'override' directive
indicates that you are Hiding (a warning) rather than overriding the
virtual method).

Since C++ now allows use of the override keyword now to explicitly say a
method is overriding a virtual function, I have been adding that in all the
code I use (or at least trying to).

Firstly, it is a visual indicator that the method is, in fact, overriding a
virtual function (which is not always obvious), but it also means that if a
virtual method changes its signature in any way, you will get an error if
an 'override' marked method no longer matches!

I'm not sure what I'm after except just to bring it to people's attention
in case they might have missed it, and find out how people view this.

My latest pull-request has changed the signature of OvmsVehicle methods and
I have added 'override' to all the places where this is overridden in
derived Vehicle classes.

//.ichael
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openvehicles.com/pipermail/ovmsdev/attachments/20230617/6c581f99/attachment.htm>


More information about the OvmsDev mailing list