GeekInterview.com
  I am new, Sign me up!
 
GeekInterview.com  >  Interview Questions  >  Programming  >  C++
Go To First  |  Previous Question  |  Next Question 
 C++  |  Question 55 of 203    Print  
What is the need /use of function overloading
Hint FO is mechanism in which two functions r having same name with diff no. of arguments.


  
Total Answers and Comments: 6 Last Update: June 06, 2006     Asked by: harsha 
  
 Sponsored Links

 
 Best Rated Answer

No best answer available. Please pick the good answer available or submit your answer.
November 10, 2005 09:53:28   #1  
susie        

RE: What is the need /use of function overloading

Funtion over loading is yet another feature of polymorphism.Diff functions with the same function name but diff arguments are defined in a class.During compile time the appropriate function is called dep on the arguments passed.Eg:

class area

{

int sq l b;

float r;

public:

draw()

{cout<< no shape };

float draw(float );

int draw(int );

int draw(int int );

};

float shape:: draw(float cir)

{

r cir;

return(3.14*r*r);

};

int shape::draw(int sq)

{

return(sq*sq);

};

int shape::draw(int l int b)

{

l (a+b);

return(2*l);

};

so dep on the arg passed we get the area of circle square or rectangle.


 
Is this answer useful? Yes | No
November 13, 2005 02:28:40   #2  
sudheeer        

RE: What is the need /use of function overloading

in overloading we use same function in somany types.


 
Is this answer useful? Yes | No
November 24, 2005 03:49:30   #3  
maheboob        

RE: What is the need /use of function overloading

in function overloading the function has single name but when it called from main function by passing different types of agruments then it behaves accroding to the passed from the function.

the function different actions based on arguments hence it's called as function overloading.

the need is that

1. rewriting of the code is not required

2. memory is saved.


 
Is this answer useful? Yes | No
February 09, 2006 14:55:37   #4  
ankur        

RE: What is the need /use of function overloading

c++ is object oriented and constructors create objects frojm dust to create objects in different ways we provide constructors with diff arguments some time without arguments ..thus function overloading is must..AS SIMPLE AS THAT


 
Is this answer useful? Yes | No
March 04, 2006 23:19:48   #5  
priya        

RE: What is the need /use of function overloading
by using function overloading we can perform different operations using same function name but one main thing is that we have to pass different arguments for all the functions so that we can perform polymorphism.
 
Is this answer useful? Yes | No
June 06, 2006 06:08:43   #6  
bappa        

RE: What is the need /use of function overloading
return type of overloading function should be same....
 
Is this answer useful? Yes | No


 
Go To Top


 Sponsored Links

 
About Us -  Privacy Policy -  Terms and Conditions -  Contact -  Ask Question -  Propose Category -  Site Updates 

Copyright © 2005 - 2009 GeekInterview.com. All Rights Reserved

Page copy protected against web site content infringement by Copyscape