brauche hilfe --> wieso ist overloaded function ambiguous?
-
hiermit wollte ich eigentlich eine ganz simple funktion überladen. beim
kompilieren kriege ich jedoch die fehlermeldung
'call of overloading addition(double, double) is ambiguouswieso?
#include <iostream>
using namespace std;int addition(int a, int b)
{
int result = a + b;
return result;
}float addition(float a, float b)
{
float result = a + b;
return result;
}int main ()
{cout << addition(5.5, 10.5);
cin.get();
}
-
5.5 ist vom Typ double und das ist von float genauso weit entfernt wie von int. Probier 5.5f .
-
cout << addition(5.5f, 10.5f);double->int
double->float
Beide Konvertierungen sind gleichwertig.Gruß
Don06
-
besten dank für die rasche hilfe
grz sandor