answersLogoWhite

0


Best Answer

Function overloading is multiple definition with different signatures(the parameters should be different) for the same function. The parameter list have to be different in each definition. The compiler will not accept if the return type alone is changed.

Operator overloading is defining a function for a particular operator. The operator loading function can not be overloaded through function overloading.

User Avatar

Wiki User

13y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

13y ago

Operator overloading means defining what the operators ie + - * / & | etc mean in terms of your object, by writing appropriate methods in the object's code. This is not permitted in java.

Method overloading is using the same method name in methods with different paramters ie

setSize(Dimension d)

setSize(int height, int width)

This answer is:
User Avatar

User Avatar

Wiki User

13y ago

Function overloading refers to using the same function name in the same scope with multiple versions depending on the parameters provided. Operator overloading is a specialized version of function overloading, and refers specifically to using operators instead of function names. These are usually designated with the keyword "operator".

Function overloading:

void doSomething(int arg1);

void doSomething(int arg1, int arg2);

Operator overloading:

obj& operator +(obj arg1, obj arg2);

This answer is:
User Avatar

User Avatar

Wiki User

10y ago

There is no difference. Operator overloads should always be implemented with an equivalent function overload. That is, an operator overload should always call the appropriate function overload, thus giving the user the option of using the operator or the function.

Indeed, aside from the relational operators (<, <=, ==, >, >= and !=) and assignment operator (=), operator overloads are not actually required unless they would allow consumers to use the object in a more intuitive way. If there is any ambiguity regarding the purpose of an operator, do not provide an operator at all -- use a function equivalent instead.

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: How operator overloading differ from function overloading?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

Operator overloading is possible in java or not?

Java does not support opperator overloading, so the answer to your question is: none.


Why a friend function cannot be used to overload the assignment operator?

Assignment(=) operator is a special operator that will be provided by the constructor to the class when programmer has not provided(overloaded) as member of the class.(like copy constructor). When programmer is overloading = operator using friend function, two = operations will exists: 1) compiler is providing = operator 2) programmer is providing(overloading) = operator by friend function. Then simply ambiguity will be created and compiler will gives error. Its compilation error.


Why do you use of operator overloading in c?

Overloading, Overriding, Polymorphism, Information Hiding, Inheritance all these are CONCEPTS of C++ and Java. An Object Oriented Language and not of C language. Thats why Bjarne Stroustrup came up with C++ ...


What are the similarities between constructor overloading and function overloading?

The only similarity is that both constructor and function overloads are distinguished by their signature -- the number and type of their arguments. Functions differ in that they also have a return type, which is also part of the signature, whereas constructors have no return type, not even void.


Rules for function overloading?

It's a way by which you use define the same function for different input types. For example, think about the the operator "+" which in java works for adding integers, floating point numbers and even string concatenation. The way such functionality is achieved is by overloading.

Related questions

Is it possible to do operator overloading in c?

No. Operator and/or function overloading is only a C++ thing.


What is an operator overloading in C?

one function but multiple behaviours depending on the parameters


Definition of operator overloading inc plus plus?

to define an additional task to an operator ,we must specify what it means in relation to the class to which the operator is applied.this is done with the help of a special function called operator function ,which describes the task.


Operator overloading is possible in java or not?

Java does not support opperator overloading, so the answer to your question is: none.


C coding for operator overloading?

C does not support operator overloading. If you mean C++ operator overloading, it depends on exactly what you wanted to do. If you wanted to '+' to strings, then you could write: string operator+(string a, string b) { // do something }


When an operator works on various type of operands is called?

operator overloading


Why a friend function cannot be used to overload the assignment operator?

Assignment(=) operator is a special operator that will be provided by the constructor to the class when programmer has not provided(overloaded) as member of the class.(like copy constructor). When programmer is overloading = operator using friend function, two = operations will exists: 1) compiler is providing = operator 2) programmer is providing(overloading) = operator by friend function. Then simply ambiguity will be created and compiler will gives error. Its compilation error.


Why do you use of operator overloading in c?

Overloading, Overriding, Polymorphism, Information Hiding, Inheritance all these are CONCEPTS of C++ and Java. An Object Oriented Language and not of C language. Thats why Bjarne Stroustrup came up with C++ ...


What are the similarities between constructor overloading and function overloading?

The only similarity is that both constructor and function overloads are distinguished by their signature -- the number and type of their arguments. Functions differ in that they also have a return type, which is also part of the signature, whereas constructors have no return type, not even void.


How can you can create a new operator through operator overloading?

You cannot create any new operators in C++. You can only overload the existing ones (although some, such as sizeof, new and delete cannot be overloaded). The only way to create a new operator is to implement it as a standard function with a named identifier. For instance, sqrt() is the standard library function that provides the square root operator, for which no real operator exists.


define function overloading?

Defining several functions with the same name with unique list of parameters is called as function overloading.


How can you differentiate overloading of pre-fix and post-fix increment operator?

The prefix increment operator is overloaded as operator++() while the postfix increment operator is overloaded as operator++(int).