What is the key difference between overriding and overloading a function in C++? 

  • Return type 
  • Number of arguments 
  • Function signature 
  • Polymorphism type
Overloading refers to defining multiple functions with the same name but different signatures (usually different number or type of parameters). Overriding, on the other hand, is related to inheritance and polymorphism where a derived class provides a specific implementation for a method that is already provided by its base class. In overriding, the method in the derived class should have the same name, return type, and parameters as the method in the base class. The key difference is thus related to polymorphism and inheritance for overriding versus method signature differences for overloading.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *