lundi 16 mars 2015

C++ Overloading resolution method


I'm trying to understand the overloading resolution method.


Why is this ambiguous:



void func(double, int, int, double) {}
void func(int, double, double, double) {}

void main()
{
func(1, 2, 3, 4);
}


but this isn't?



void func(int, int, int, double) {}
void func(int, double, double, double) {}

void main()
{
func(1, 2, 3, 4);
}


In the first case there are 2 exact parameters matches and 2 conversions against 1 exact match and 3 conversions, and in the second case there are 3 exact matches and 1 conversion against 1 exact matches and 3 conversions.


So why is one ambiguous and one is not? What is the logic here?




Aucun commentaire:

Enregistrer un commentaire