# conversion, promotion, exact match

Discussion in 'C++' started by Andy, Sep 7, 2005.

1. ### AndyGuest

Hi...

c++.
to understand the resolving system it's important to understand the
diffrent
levels of typecasting (exact match, promotion, conversion, not
possible)

that is, what i don't really understand. so i tried do make a little
table:

| bool | char | unsig int | int | float | double
-----------------------------------------------------------
bool into | EM | PRO | PRO | PRO | |
-----------------------------------------------------------
char into | | EM | PRO | PRO | PRO | PRO
-----------------------------------------------------------
unsig into | | | EM | | |
-----------------------------------------------------------
int into | CON | CON | | EM | CON | CON
-----------------------------------------------------------
float into | | | | | EM | PRO
-----------------------------------------------------------
double into| CON | | | | | EM

(e.g.: float into double: PRO)
EM= exakt match
PRO= promotion
CON= conversion
NP= not possible

it would be a great help for me if someone could correct and complete
this table.

thanks a lot...

andy

Andy, Sep 7, 2005

2. ### AndyGuest

Andy schrieb:

> Hi...
>
> i'm trying to understand the concept of function name overloading in
> c++.
> to understand the resolving system it's important to understand the
> diffrent
> levels of typecasting (exact match, promotion, conversion, not
> possible)
>
> that is, what i don't really understand. so i tried do make a little
> table:
>
> | bool | char | unsig int | int | float | double
> -----------------------------------------------------------
> bool into | EM | PRO | PRO | PRO | |
> -----------------------------------------------------------
> char into | | EM | PRO | PRO | PRO | PRO
> -----------------------------------------------------------
> unsig into | | | EM | | |
> -----------------------------------------------------------
> int into | CON | CON | | EM | CON | CON
> -----------------------------------------------------------
> float into | | | | | EM | PRO
> -----------------------------------------------------------
> double into| CON | | | | | EM
>
> (e.g.: float into double: PRO)
> EM= exakt match
> PRO= promotion
> CON= conversion
> NP= not possible
>
> it would be a great help for me if someone could correct and complete
> this table.

sorry for being impatient, but i'm just wondering why nobody answers to
my post.
is it useless to make a table like intended to do, or did i violate a
rule and my post is not as post need to be in this group?

Andy, Sep 10, 2005

3. ### John HarrisonGuest

Andy wrote:
> Andy schrieb:
>
>
>>Hi...
>>
>>c++.
>>to understand the resolving system it's important to understand the
>>diffrent
>>levels of typecasting (exact match, promotion, conversion, not
>>possible)
>>
>>that is, what i don't really understand. so i tried do make a little
>>table:
>>
>> | bool | char | unsig int | int | float | double
>>-----------------------------------------------------------
>>bool into | EM | PRO | PRO | PRO | |
>>-----------------------------------------------------------
>>char into | | EM | PRO | PRO | PRO | PRO
>>-----------------------------------------------------------
>>unsig into | | | EM | | |
>>-----------------------------------------------------------
>>int into | CON | CON | | EM | CON | CON
>>-----------------------------------------------------------
>>float into | | | | | EM | PRO
>>-----------------------------------------------------------
>>double into| CON | | | | | EM
>>
>>(e.g.: float into double: PRO)
>>EM= exakt match
>>PRO= promotion
>>CON= conversion
>>NP= not possible
>>
>>it would be a great help for me if someone could correct and complete
>>this table.

>
>
> sorry for being impatient, but i'm just wondering why nobody answers to
> my post.
> is it useless to make a table like intended to do, or did i violate a
> rule and my post is not as post need to be in this group?
>
>

You didn't violate any rules, I guess no-one found your topic
interesting or important enough to answer.

The C++ standard actually allows some leeway to implementors so I don't
think you can write one table that would work for all implementations.
For instance char -> unsigned int is a conversion if char is signed but
a promotion if char is unsigned.

Your table has some mistakes, bool to char is a conversion for instance,
There are no promotions to char. char to unsigned int may be a promotion
or a conversion, as explained above.

All the blanks in your table are conversions.

Hopefully that gives you enough information to complete the table.

john

John Harrison, Sep 10, 2005