+ 3

In CPP How are function and operator overloading part of polymorphism...?

Having a virtual method in the base class will aid the derived classes to have polymorphic abilities..But how are function overloading and operator overloading a part of polymorphism? Textbook definitions of polymorphism is That a call to a member function will cause a different function to be executed depending on the type of object that invokes the function. If the base class have non virtual overloaded functions and derived classes have it too how can it be polymorphic ?

19th Feb 2018, 12:26 PM
Fabricated Reality
Fabricated Reality - avatar
1 Answer
+ 7
if you call that function on object of base class it will be executed that method in base class, if you call on object of derived class function in that class will be executed, different objects execute same function in different ways and that is polymorphism
19th Feb 2018, 6:33 PM
Vukan - avatar