function overloading vs function overriding

Function Overloading in C++ means we can define same function with different signatures (different set of parameters) and create family of function whereas Function Overriding means derived class can rewrite body of the method of base class.

a) In overloading, there is a relationship between methods available in the same class whereas in overriding, there is a relationship between a base class method and subclass method.

(b) Overloading does not block inheritance from the base class whereas overriding blocks inheritance from the base class.

(c) In overloading, separate methods share the same name whereas in overriding, derived class method replaces the base class method.

(d) Overloading must have different method signatures whereas overriding must have same signature.

No comments:

Post a Comment