conversion, promotion, exact match

A

Andy

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.

thanks a lot...

andy
 
A

Andy

Andy said:
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?

please answer me!
 
J

John Harrison

Andy said:
Andy schrieb:




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?

please answer me!

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,535
Members
45,008
Latest member
obedient dusk

Latest Threads

Top