Friday, July 16, 2010

Polymorphism

Polymorphism, although mostly referred to virtual function usage, can actually be categorized into two different types
  • Static Polymorphism: refers to the ability of having overrided functions in one scope
  • Dynamic Polymorphism: Refers to the ability to override functions that are called virtual in the parent class
Please notice that if we have a non-virtual function in the parent class and weoverride it in the child class it is still called Static Polymorphism. Lots of people use the terminology in the context of virtual functions, but it is better to consider the actual meaning that is "has many forms" The other important misunderstanding that is related somehow, is that C++ not only introduced polymorphism in form of virtual function overriding, it also introduced function overloading. Function overloading was not a part of the C language and is new in C++.

No comments:

Post a Comment