How to learn which are conversions and promotions in function calls?.
From my previous question related to why are some functions called despite of others could have also been called too, i want to underline three keywords: conversions, promotions, perfect matches.
perfect matches is the simplest:
int fun(int a)
called with a variable declaredint x;
int fun(float a, double b)
called with a variable declaredfloat x;
double y;
int fun(char a, string s)
called with a variable declaredchar x;
string y
- ...etc
for conversions and promotions i'm only going to mention that:
Numeric conversions: Unlike the promotions, numeric conversions may change the values, with potential loss of precision.
Numeric promotions: a conversion from a smaller type to a larger same type (E.g char to int), but without any loss of content
Here comes the part that is not that simple. I would like someone to explain the way you need to think when you analize the function parameters for different situations as calling:
int fun(double a)
withfloat x
vsint fun (float a)
called withdouble x
I would like to actual see some examples, because for a begginer is not easy to understand the references from cpp.