Difference between Operator overloading and Functional
overloading?

Answer Posted / jknjkjk

Function overloading is like you have different functions
with the same name but different signatures working
differently. So, the compiler can differentiate and find
out which function to call depending on the context. In
case of operator overloading, you try to create your own
functions which are called when the corresponding operator
is invoked for the operands.

One important thing to understand is that you can create as
many functions as you want with the same name and sifferent
signatures so that they can work diffrently but for a
particular class, you cannot overload the operator function
based on number of arguments. There is a fundamental reason
behind this.

According to the rules, you can not create your own
operators but you have to use already available operators.
Another thing is since the operator are already defined for
use with buily-in types you can not change their
charecteristics. For example the binary operator '+' always
takes two parameters, so for this you cannot create a
function that takes three parameters. But you can always
overload them based on the type of the parameters.

Is This Answer Correct ?    13 Yes 16 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is set in c++?

668


I want explanation for this assignment: how to connect mysql database using c/c++,please explain this detailly?

1591


What is vector processing?

677


What is a constant? Explain with an example.

567


Explain the difference between overloading and overriding?

627






What information can an exception contain?

675


Name four predefined macros.

603


Are c and c++ different?

555


Please explain class & object in c++?

612


How is computer programming useful in real life?

606


Why c++ does not have finally?

605


What is the type of this pointer in c++?

646


Which is better c++ or java?

577


Assume studentNames and studentIDs are two parallel arrays of size N that hold student data. Write a pseudocode algorithm that sorts studentIDs array in ascending ID number order such that the two arrays remain parallel.

1723


What are c++ redistributables?

570