alanpong
asked on
char() vs (char)
win2k, vc++6.0
What is the different between :
DWORD dw;
char a = char(dw);
char b = (char)dw;
Is char() a marco or a function?
which *.h file can i found its definition?
Thank you very much.
Rgds.
Alan
--END
What is the different between :
DWORD dw;
char a = char(dw);
char b = (char)dw;
Is char() a marco or a function?
which *.h file can i found its definition?
Thank you very much.
Rgds.
Alan
--END
ASKER
i know (char)dw is a casting.
how about this?
char a = char(dw);
is char( X ) a marco or function?
or standard c++ usage?
is char(dw) equalivent to (char) dw?
--END
how about this?
char a = char(dw);
is char( X ) a marco or function?
or standard c++ usage?
is char(dw) equalivent to (char) dw?
--END
>is char(dw) equalivent to (char) dw?
>char a = char(dw);
it's like you call the constructor of a class with a value
>char a = char(dw);
it's like you call the constructor of a class with a value
ASKER
>it's like you call the constructor of a class with a value
can i found its definition in .h file?
(char)dw should be faster than char(dw)?
can i found its definition in .h file?
(char)dw should be faster than char(dw)?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
>>(char)dw should be faster than char(dw)?
>it's the same
struct s
{
int z;
} s;
char c = (char) s;
char d = char(s);
yes, proved, the compiler tell me both assignments above is trying to do type casting.
error C2440: 'type cast' : cannot convert from 'struct s' to 'char'
error C2440: 'type cast' : cannot convert from 'struct s' to 'char'
>it's the same
struct s
{
int z;
} s;
char c = (char) s;
char d = char(s);
yes, proved, the compiler tell me both assignments above is trying to do type casting.
error C2440: 'type cast' : cannot convert from 'struct s' to 'char'
error C2440: 'type cast' : cannot convert from 'struct s' to 'char'
The char type is used to store the integer value of a member of the representable character set. That integer value is the ASCII code corresponding to the specified character.
>char b = (char)dw;
here you used the cast operator (see http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vclang/html/vcrefCastOperator.asp)