Announcement

Collapse
No announcement yet.

Both virtual and override?

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

    Both virtual and override?

    I see in the coding style guide:

    "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.

    #2
    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.
    | Finite State Machine | Savior | USQLite | Object-Pool | Sound-Occlusion | Property Transfer | Magic Nodes | MORE |

    Comment


      #3
      Those specifications are in general for engine contributions.
      Yes - I understand that. If/when I submit anything of course I would follow the style.

      Just trying to understand the rationale since it's just more noise when trying to navigate/parse/understand the code.

      Thought I might be missing a good reason - like a compiler that doesn't support C++11 properly.

      Comment


        #4
        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.

        Comment


          #5
          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.

          Comment

          Working...
          X