|
|
Function Overloading in C++
|
Tutorials

Cpp

|
Topic |
What is Function Overloading in C++?
|
|
Explanation |
|
Function Overloading is a method to define multiple functions with the same name. But
different tasks are performed based on the number, type of arguments contained in that function.
Example:
#include <iostream.h>
int add(int, int);
double add( double , double );
int add(int , int , int );
int main()
{
cout << "Addition of 2 integers::"
<
|
Result:
Addition of 2 integers::13
Addition of 2 double integers::25.7
Addition of 3 integers::30
In the above example there are multiple "add" functions, but with different arguments, types. So based on the type and arguments
the respective function is called.
|
| Note |
C++ is one of the most used programming languages in the world. Also known as "C with Classes".
Hope you enjoy this tutorial. Do send your feedback or suggestions on this C++ tutorial. This is a copyright content.
|
|
|
|