in funcation overloading we can use a funcation with same name that have different perameters but it is showing error that ""call of overloaded 'add(double, double)' is ambiguous""!
# include <iostream>
usingnamespace std;
class addition
{
int a,b,sum;
double n,m,sumf;
public:
int add(int,int);
double add(double,double);
};
int addition::add(int x,int y)
{
a=x;
b=y;
sum = a+b;
return(sum);
}
double addition::add(double x,double y)
{
n=x;
m=y;
sumf = n+m;
return(sumf);
}
int main()
{
int q;
double w;
addition o;
q = o.add(2,3);
cout << q << endl;
w = o.add(3.2,4.5);
cout << w << endl;
return 0;
}
because all floating-point literals in C++ are automatically of type double,when there is no double formal paramter the compiler cannot decide which to call add(float,float) or add(int,int)