Override explanation

So, the challenge is: explain what override is in as few words as possible.
Correct me if I’m wrong, please.

Override: to change an inherited method.

That is correct. An example would be if you have a class called Character that has a doDamage() method. Then you make a class called Hero that inherits Character, you would be able to call .doDamage() on the Hero character, but it’s not quite what you want. So you could then have the Hero class override the doDamage() method to use it’s own.

Yeah, basically one of the benefits of polymorphism besides overloading.

Privacy & Terms