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

Can we run c program in turbo c++?

567


What is the difference between c++ and turbo c++?

576


What are the types of array in c++?

606


What is capacity in vector in c++?

531


How many static variables are created if you put one static member into a template class definition?

553






Suppose that data is an array of 1000 integers. Write a single function call that will sort the 100 elements data [222] through data [321].

941


Can a new be used in place of old mallocq? If yes, why?

624


What is time_t c++?

594


Why do we use setw in c++?

631


What is split a string in c++?

680


What is the difference between a "copy constructor" and an "assignment operator" in C++?

609


What is virtual function? Explain with an example

577


What are files in c++?

581


What is a string example?

535


Do vectors start at 0 c++?

517