What is Polymorphism?
Polymorphism allows objects to be represented in multiple forms. Even
though classes are derived or inherited from the same parent class, each
derived class can have its own behaviour. Polymorphism is a concept linked
to inheritance and assures that derived classes have the same functions
even though each derived class performs different operations.
though classes are derived or inherited from the same parent class, each
derived class can have its own behaviour. Polymorphism is a concept linked
to inheritance and assures that derived classes have the same functions
even though each derived class performs different operations.
Polymorphism is important not only to the derived classes, but to the base classes as well. Designers of a base class can anticipate the aspects of their base class that are likely to change for a derived type. For example, a base class for cars might contain behaviour that is subject to change when the car in question is a minivan or a convertible. A base class can mark those class members as virtual, allowing derived classes representing convertibles and minivans to override that behaviour.
No comments:
Post a Comment