How does function-style cast syntax work?
I guess I am a bit puzzled by the syntax. What does the following mean?
typedef char *PChar;
hopeItWorks = PChar(开发者_开发技巧 0x00ff0000 );
It is equivalent to (PChar) 0x00ff0000
or (char *) 0x00ff0000
. Syntactically think of it as invoking a one-argument constructor.
SomeType(args)
means explicit constructor call if SomeType
is user-defined type and usual c-cast (SomeType)args
if SomeType
is fundamental type or a pointer.
PChar
is equivalent to char *
(pointer). Thus hopeItWorks = (char *)0x00ff0000;
typedef char *PChar;
Its typedef of char*
to Pchar
. Instead of using char*
you can define variables with Pchar.
hopeItWorks = PChar( 0x00ff0000 );
Its equivalent to ==>
hopeItWorks = (char *)( 0x00ff0000 );
精彩评论