Difference between Overloading and Overriding?

Answer Posted / vetrivel

Overloading vs. overriding

1.Overriding of functions occurs when one class is inherited from another class. Overloading can occur without inheritance.
2.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.
3.Overridden functions are in different scopes; whereas overloaded functions are in same scope.
4.Overriding is needed when derived class function has to do some added or different job than the base class function.
5.Overloading is used to have same name functions which behave differently depending upon parameters passed to them.

Is This Answer Correct ?    1 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What do nonglobal variables default to a) auto b) register c) static

650


Can turbo c++ run c program?

631


Is map thread safe c++?

634


Are there interfaces in c++?

558


What is c++ runtime?

659






How would you obtain segment and offset addresses from a far address of a memory location?

620


What is math h in c++?

607


On throwing an exception by the animal constructor in p = new animalq, can memory leak occur?

683


What is class invariant in c++?

746


Explain deep copy and a shallow copy?

614


What does new return if there is insufficient memory to make your new object?

589


What is the default access level?

623


What kind of jobs can I get with c++?

599


Which function cannot be overloaded c++?

578


Is it possible for a member function to delete the pointer, named this?

616