“Use the virtual and override keywords when declaring an overriding method. When declaring a virtual function in a derived class, that overrides a virtual function in the parent class, you must use both the virtual and the override keywords.”
Anyone know why both are required by the style? virtual is redundant when override is specified, so it just adds to the verbosity.
Those specifications are in general for engine contributions.
For example when submitting a PR I follow Epic 100%, when doing external code I use auto-formatting scripts with whatever style I want to use in VisualStudio.
The good reason is that it becomes more obvious what they’re doing. Half of the unreal code style is about writing as verbose as you can to help other readers.
Thanks Zeblote. I 100% agree that code should be written for humans. I don’t agree that verbosity (always) implies clarity.
The virtual keyword in this case doesn’t add any information or make anything easier to understand. A function declared using override is virtual so it’s completely redundant.
So I don’t understand how this makes it more obvious what they’re doing.
But we can disagree Just wondered if I was missing something.
I found this post via google search, had been wondering the same thing: Why does UE coding standard explicitly say:
"When declaring a virtual function in a derived class that overrides a virtual function in the parent class, you must use both the virtual and the override keywords
especially when the ISO C++ Core Guidelines (edited by Bjarne Stroustroup and Herb Sutter) say the opposite (and IMO with some good reasoning):