• We need your support!

    We are currently struggling to cover the operational costs of Xtremepapers, as a result we might have to shut this website down. Please donate if we have helped you and help make a difference in other students' lives!
    Click here to Donate Now (View Announcement)

Function Overloading and Operator Overloading

Messages
26
Reaction score
3
Points
3
Hello Friends,

What is function overloading and operator overloading in C++ ??
Please anyone give the answer of this question
 
Messages
878
Reaction score
1,474
Points
153
Operator overloading and function overloading are both very much alike... i assume you're studying polymorphism

Operator overloading is basically using the same operator to perform different operations.
a popular example is using '+" operator to perform addition of numbers and concatenation of strings..
e.g
addition = 2 + 2
string = "Hello" + "world"
FullName = FName + LName


Now function overloading...In OOPs like C++, multiple functions can be written under the same name, provided that they differ in argument types and/or numbers.
e.g
void info(char *name); // if we call info(Bob) this function is executed
void info(char *name, int age); // if we call info(Bob, 18) this function is executed


Another example would be using int type and float type...we can have different types of arguments..the compiler will decide which function is called by looking at the return type (e.g float, char, int) and the number of arguments passed

see this link:

http://www.codersource.net/c/c-tutorials/c-tutorial-function-overloading.aspx
 
Messages
26
Reaction score
3
Points
3
Operator overloading and function overloading are both very much alike... i assume you're studying polymorphism

Operator overloading is basically using the same operator to perform different operations.
a popular example is using '+" operator to perform addition of numbers and concatenation of strings..
e.g
addition = 2 + 2
string = "Hello" + "world"
FullName = FName + LName


Now function overloading...In OOPs like C++, multiple functions can be written under the same name, provided that they differ in argument types and/or numbers.
e.g
void info(char *name); // if we call info(Bob) this function is executed
void info(char *name, int age); // if we call info(Bob, 18) this function is executed


Another example would be using int type and float type...we can have different types of arguments..the compiler will decide which function is called by looking at the return type (e.g float, char, int) and the number of arguments passed

see this link:

http://www.codersource.net/c/c-tutorials/c-tutorial-function-overloading.aspx


Thanks for describing this in easy way ..
I understand the concept of function overloading ............. Thanks for sharing this ....
:) :) :)
 
Top