Polymorphism
Polymorphism refers to the ability to process objects differently depending
on their data type or class. Additionally it provides the ability to redefine
methods for derived classes. For example, given a base class of Employee, polymorphism
enables the programmer to define different PayEmployee methods for any
number of derived classes, such as Hourly or Salaried or Commissioned. No matter
what type of Employee an object is, applying the PayEmployee method to
it will return the correct results.
Class Employee
Function PayEmployee()
PayEmployee = Hours * HourlyRate
End Function
Class CommissionedEmployee
Inherits Employee
Overrides Function PayEmployee()
PayEmployee = BasePay + Commissions
End Function