What is the purpose of the 'override' keyword in header declarations?

Hello! After creating my first Actor class, I notice in the header file, that the BeginPlay() and Tick() functions are set up in a bizarre way.

virtual void BeginPlay() override;

for instance.

I’ve never seen a virtual function declaration with the override keyword directly in it, and was wondering if someone could explain how/why this is included? As far as my C++ knowledge goes, you set up a pure virtual function in your base class declaration, and the DERIVED classes may contain the override keyword.
_
Something like this:
_

class BaseClass{
public:
virtual void doSomething(){cout<<1;}
};

class DerivedClass: public BaseClass{
public:
void doSomething() override{cout<<2;}
}

_
in your main code, you could call the function and it would print 2, rather than 1. This I understand.
_

The way UE4 seems to have it set up, though, just looks different and is confusing to me in how it would operate, or why it is declared that way.

I know that my wording is rather ■■■■-poor, and not very technical. I apologize for this and ask that you please bear with me. This has perplexed me all evening, searching through countless tutorials and sifting through the documentation to no avail.
_
If you’ve even taken the time to read this, Thank you; I appreciate any answers!

Technicly speaking you don´t need virtual or override in the derived class to actually override the Function. It overrides just fine aslong the basclass has the virtual Keyword.

Those Keywords make sure in case you change the baseclass to be none virtual or finalize a virtual function to throw you a Compile Time Error since there would be no functionality anymore to override. It makes spotting Bugs related to that easier since you get a Error beforehand and don´t have to figure out why your Function all of a sudden does not execute anymore. Aswell as making it easier for you to know that you override something when looking at the definition.

The override Keyword alone should be enough if you preffer it that way.

Thank you for the explanation!

THIS.

Thank you so, so much! This is exactly what I was referring to, and now I believe I understand! Thank you for linking extra reading for me as well, always appreciated :smiley:

Cheers!

You are correct in your understanding how the override keyword should be used.

Are you referring to the code automatically added to your class when it’s generated? If so, the override keyword is used because you are overriding Actor’s versions of the functions. Your class inherits from Actor.

This post explains it pretty well: c++ - Should I use virtual, override, or both keywords? - Stack Overflow