GeekInterview.com
  I am new, Sign me up!
 
GeekInterview.com  >  Interview Questions  >  Programming  >  C++
Go To First  |  Previous Question  |  Next Question 
 C++  |  Question 137 of 203    Print  
What is the difference between function overloading and operator overloading?

  
Total Answers and Comments: 4 Last Update: November 16, 2008     Asked by: tamilmani 
  
 Sponsored Links

 
 Best Rated Answer

No best answer available. Please pick the good answer available or submit your answer.
July 04, 2007 09:41:15   #1  
John Abraham        

RE: What is the difference between function overloading and operator overloading?
Function overloading is the practice of declaring the same function with different signatures. The same function name will be used with different number of parameters and parameters of different type. But overloading of functions with different return types are not allowed.

On the other hand operator overloading is:

Operating overloading allows you to pass different variable types to the same function and produce different results. In this article Ben gives us the low-down on operator overloading in C++.Operator overloading is common-place among many efficient C++ programmers. It allows you to use the same function name but as different functions.

And that is the difference.

Qwerty Maniac
http://yahoo.com/

 
Is this answer useful? Yes | NoAnswer is useful 0   Answer is not useful 1Overall Rating: -1    
November 26, 2007 01:07:03   #2  
vinod kumar        

RE: What is the difference between function overloadin...
Function overloading: In this we can call same function one or more times. That is function body will execute repeatedly.

Operator over loading: In this we can perform one or more operations by using one operator.

 
Is this answer useful? Yes | NoAnswer is useful 0   Answer is not useful 1Overall Rating: -1    
December 05, 2007 08:40:06   #3  
Adam Pond Member Since: December 2007   Contribution: 1    

RE: What is the difference between function overloading and operator overloading?
Unfortunately Vinod is not correct.

John Abraham provided a very good and accurate description of the answer.

 
Is this answer useful? Yes | No
November 16, 2008 03:23:47   #4  
mucdull Member Since: November 2008   Contribution: 6    

RE: What is the difference between function overloading and operator overloading?
The statement "But overloading of functions with different return types are not allowed." is incorrect. Function overloading only disallows overloading of functions with the same signatures but different return types. It is ok to return a different return type if you have a different signature.

One difference between function and operator overloading is that operator overloading is more restrictive. A restriction on operator overloading is that you cannot change the meaning of built-in operators. That means you cannot do this:

int& operator+(int& x int& y){...}

Also some operators such as the :: cannot be overloaded.

 
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