C++ Virtual Functions Question:

Download Job Interview Questions and Answers PDF

Can you please explain the difference between Overloading and Overriding?

C++ Virtual Functions Interview Question
C++ Virtual Functions Interview Question

Answer:

Overriding of functions occurs when one class is inherited from another class. Overloading can occur without inheritance.
Overloaded functions must differ in function signature ie either number of parameters or type of parameters should differ. In overriding, function signatures must be same.
Overridden functions are in different scopes; whereas overloaded functions are in same scope.
Overriding is needed when derived class function has to do some added or different job than the base class function.
Overloading is used to have same name functions which behave differently depending upon parameters passed to them.

Download C++ Virtual Functions Interview Questions And Answers PDF

Previous QuestionNext Question
What is Virtual Table?Do you know the problem with overriding functions?