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


Please Help Members By Posting Answers For Below Questions

explain sub-type and sub class? atleast u have differ it into 4 points?

1832


What is polymorphism and its types?

594


What is an interface in oop?

593


I have One image (means a group photo ) how to split the faces only from the image?............ please send the answer nagadurgaraju@gmail.com thanks in advace...

1626


hi, this is raju,iam studying b.tech 2nd year,iam want know about group1 and group2 details, and we can studying without going to any instutions? please help me.

1541






State what is encapsulation and friend function?

699


Why is destructor used?

582


Write a C++ program without using any loop (if, for, while etc) to print prime numbers from 1 to 100 and 100 to 1 (Do not use 200 print statements!!!)

1639


Can private class be inherited?

617


What is multilevel inheritance in oop?

557


What is the main feature of oop?

618


How does polymorphism work?

635


When not to use object oriented programming?

570


Question: Write a program that prints a paycheck. Ask the program user for the name of the employee, the hourly rate, and the number of hours worked. If the number of hours exceeds 40, the employee is paid “time and a half”, that is, 150 percent of the hourly rate on the hours exceeding 40. Be sure to use stepwi se refine ment and break your solution into several functions. Use the int_name function to print the dollar amount of the check.

697


program for insertion ,deletion,sorting in double link list

2279