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

Is facebook written in c++?

558


Explain one method to process an entire string as one unit?

921


Differentiate between a copy constructor and an overloaded assignment operator.

635


How much do coding jobs pay?

545


Can you be able to identify between straight- through and cross- over cable wiring? And in what case do you use straight- through and cross-over?

615






Is it legal in c++ to overload operator++ so that it decrements a value in your class?

604


What is c++ namespace?

707


How is data hiding achieved in c++?

565


How do you remove an element from a set in c++?

576


Can a constructor return a value?

570


What do c++ programmers do?

547


What does return 0 do in c++?

574


Give the difference between the type casting and automatic type conversion. Also tell a suitable C++ code to illustrate both.

624


Can I create my own functions in c++?

591


Comment on c++ standard exceptions?

628