What is function overloading and operator overloading?
Answer Posted / sagar sapkota
A function is overloaded when same name is given to different function. However, the two functions with the same name will differ at least in one of the following.
a) The number of parameters
b) The data type of parameters
c) The order of appearance
These three together are referred to as the function signature.
For example if we have two functions :
void foo(int i,char a);
void boo(int j,char b);
Their signature is the same (int ,char) but a function
void moo(int i,int j) ; has a signature (int, int) which is different
While overloading a function, the return type of the functions need to be the same.
In general functions are overloaded when :
1. Functions differ in function signature.
2. Return type of the functions is the same.
Operator overloading allows existing C++ operators to be redefined so that they work on objects of user-defined classes. Overloaded operators are syntactic sugar for equivalent function calls. They form a pleasant facade that doesn't add anything fundamental to the language (but they can improve understandability and reduce maintenance costs).
| Is This Answer Correct ? | 8 Yes | 2 No |
Post New Answer View All Answers
What does I oop mean?
What does oop mean in snapchat?
Can you explain polymorphism?
What is class and object in oops?
What is destructor oops?
What is the importance of oop?
What is persistence in oop?
Why can't we have instance(stack) of a class as a member of the same class like eg.Class A{A obj;} as we can have self refential pointer
Can bst contain duplicates?
Who invented oop?
What is polymorphism what are the different types of polymorphism?
What is the real time example of inheritance?
What is abstraction encapsulation?
any one please tell me the purpose of operator overloading
What is polymorphism what is it for and how is it used?