Virtual Methods

In this lesson, we'll discuss virtual methods in detail.

Why do we use virtual methods? #

  • Virtual methods are used to adjust the behavior of an object while keeping its interface stable.
  • In order to override a method, it must be declared virtual.

For documentation purposes, the overriding method will also be declared as virtual.

Example #

Get hands-on with 1400+ tech skills courses.