Function Overloading in C++
Master C++ with Real-time Projects and Kickstart Your Career Start Now!!
Program 1
// Program for function overloading
#include<iostream>
#define clrscr() system("cls")
using namespace std;
double area(double );
double area(double,double);
int main()
{
clrscr();
cout<<"\nArea of circle: "<<area(12.44);
cout<<"\nArea of Rectangle: "<<area(12.4,6.8);
return 0;
}
double area(double r)
{
double A;
A=3.14*r*r;
return A;
}
double area(double l,double w)
{
double A;
A=l*w;
return A;
}
// int add(int,int);
// int add(int,int,int);
// int main()
// {
// int x;
// x=add(10,20);
// cout<<x<<"\n";
// x=add(100,200,300);
// cout<<x;
// return 0;
// }
// int add(int a,int b,int c)
// {
// int d;
// d=a+b+c;
// return d;
// }
// int add(int a,int b)
// {
// int d;
// d=a+b;
// return d;
// }
If you are Happy with DataFlair, do not forget to make us happy with your positive feedback on Google

