"Jack Adam" <ja*******@gmx.net> wrote in message
news:bo**********@newsg1.svr.pol.co.uk...
Michael Gaab wrote:
function signature -
void foo(short);
function call -
foo('d');
My compiler does not complain when I call foo() with a character
argument. I am assuming that the compiler does some type casting or that char's
are interpreted as a byte. Not exactly sure.
This is normal. There is an implicit type conversion from char to short
and this is part of the C++ language, not some special compiler feature.
I am afraid you are wrong. There is not implicit type conversion from char
to short in C++ language. There is the integral promotion from char to int
(or unsigned int) that is not an integral conversion. So, as far as char is
not an integer type, though signed char and unsigned char are integers, it
shall be promoted to int and then converted (integral convertion) to short
to make the foo(short) call.
BTW that is why void foo(int); is better then void foo(short); for foo('d')
call.
--
Michael Kochetkov.