Function Overloading in C++
Function Overloading in C++
Function overloading is a feature of object-oriented programming where two or more functions can have the same name but different parameters. When a function name is overloaded with different jobs it is called Function Overloading.
If multiple functions having same name but parameters of the function should be different is called as Function Overloading . Function overloading may or may not have different return types but they must have different parameters.
In function overloading, the function is redefined by using either different types of arguments or a different number of arguments. It is only through these differences compiler can differentiate between the functions.
CODE :
#include <iostream>
using
namespace
std;
void
add(
int
a,
int
b)
{
cout <<
"sum = "
<< (a + b);
}
void
add(
int
a,
int
b,
int
c)
{
cout << endl <<
"sum = "
<< (a + b + c);
}
// Driver code
int
main()
{
add(10, 2);
add(5, 6, 4);
return
0;
}
sum = 12 sum = 15
Topics Covered :
- function overloading in c++
- what is function overlaoding
- functions
- c++ functions
- c++ programming tutorial
- c++
- c++ for beginners
Thanks for reading this blog. Hope you get satisfied with the blog and definitely this blog must have valued your time and effort of reading.
Take a time to connect our other digital creations such as Instagram , Facebook and Youtube.
Social Media Links of Tech DCode :
YouTube : https://www.youtube.com/channel/UCjJnEdeugftBwQ3yMuD4B_A
Instagram : https://www.instagram.com/thetechdcode/
Facebook Page : https://www.facebook.com/thetechdcode
Twitter : https://twitter.com/thetechdcode
Telegram Channel : https://t.me/thetechdcode
Tech DCode Linktree : https://linktr.ee/thetechdcode
My Personal Handles : https://linktr.ee/virtualshivamin
Social Media Links of SHIVAM SINGH (OWNER) :
Instagram : https://www.instagram.com/virtualshivamin/
Facebook Page : https://www.facebook.com/virtualshivamin/
Twitter : https://twitter.com/virtualshivamin/
Personal Linktree : https://linktr.ee/virtualshivamin