So far, we have learned 642-642 that we can add new data and functions to a class through inheritance. But what about if we want our derived class to inherit a method from the base class, but to have a different implementation for it? That is when we are talking about polymorphism, a fundamental concept in OOP programming.
As seen previously in the is subdivided in two concepts static polymorphism and dynamic polymorphism, 642-825 this section concentrates on dynamic polymorphism, which applies in C++ when a derived class overrides a function declared in a base class.
We implement this concept redefining the method in the derived class. However, we need to have a some 642-892 considerations when we do this, so we must introduce now the concepts of dynamic binding, static binding and virtual methods.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment