What is the difference between function overloading and operator overloading?

Showing Answers 1 - 30 of 30 Answers

John Abraham

  • Jul 4th, 2007
 

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/

  Was this answer useful?  Yes

vinod kumar

  • Nov 26th, 2007
 

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.

  Was this answer useful?  Yes

mucdull

  • Nov 16th, 2008
 

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.

  Was this answer useful?  Yes

anshu singh

  • Mar 29th, 2015
 

function overloading is a way by which we can use more than one function having same name but different argument where as operator overloding is a way by which we can use more than one operator in a single function

  Was this answer useful?  Yes

Eric Nantel

  • Apr 23rd, 2015
 

Both are functions or methods , but the signature of an operator is using a symbol

  Was this answer useful?  Yes

Kiran Bhagat

  • Nov 26th, 2015
 

Function overloading refers to use of same name for different function.

Operator overloading refers to the process of making an operator to exhibit different behavior in different instances.

  Was this answer useful?  Yes

Aarish

  • Apr 20th, 2016
 

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.

  Was this answer useful?  Yes

Zebo Li

  • Jan 26th, 2017
 

Is the following example a function overloading?
double max(double, double)
int max(int, int)
They have different return types.

  Was this answer useful?  Yes

Krishna Agrawal

  • Dec 7th, 2017
 

In order to overload function ex: void add(int x=5, int y=8) now just call in mains add(), then call add(5), then call add(3,3) in three instances function will work accordingly but in operator overloading, if you modified + operator then definition of + will not change and also new definition also work .This is called operator overloading.

  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