Explain about Overloading and Overriding

Questions by prettyfox

Showing Answers 1 - 15 of 15 Answers

Usually in an object oriented design approach, polymorphism is implemented by Overriding the member functions, but even same function names with different signatures qualify as polymorphic and this type of overload driven polymorphism is called Ad-Hoc Polymorphism.

Timothy

  • Oct 24th, 2011
 

The main difference between overloading and overriding is
that in overloading we can use same function name with
different parameters for multiple times for different tasks
with on a class.

and overriding means we can use same name function name
with same parameters of the base class in the derived class.
this is also called as re usability of code in the programme.

  Was this answer useful?  Yes

Aleem Khowaja

  • Oct 27th, 2011
 

Overloading:

In overloading we can use same name of function but different argument, it is used for perform task for different purpose.....

Example:
void Add(int a, int b){
}
void Add(int a, int b, int c){
}

void Add(int a, int b, int c, int d){
}

Overriding

In Overriding we can use same name of function and also same argument, we can used these function for different purpose just like say two function name print have a same argument one is print triangle and other is print rectangle....

Example:

class A{

void print(){

cout<<"Triangle"< }

void print(){

cout<<"Rectangle"< }

Code
  1.  

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions