Re: reinterpret_cast
- From: "anton bassov"<xxx@xxxxxxx>
- Date: Mon, 17 Apr 2006 19:04:08 -0500
Hi Carl
Look at the statment below:
///////////
That's incorrect. struct/class makes no difference: the C-style cast still
behaves like static_cast, not reinterpret_cast, regardless of whether the
types were declared using the class keyword or the struct keyword. In fact,
in such cases the C cast is always equivalent to static_cast (which will
produce the same result as reinterpret_cast in some cases).
/////////
This is wrong, believe me - the only reason why I mentioned it is because I
actually tried to change struct to class in the example that you have
presented. When I compiled it with struct, everything went the way you have
said. However,
when I changed it to class, I got the compile error, telling me that "static
cast exists, but is unavailable". There was no problem with reinterpret_cast.
Therefore, I removed static_cast, and tried to run the program - C-style
cast and reinterpret_cast worked the same way, and both returned wrong
results(they both returned a pointer to class A, rather than to class B)
Regards
Anton Bassov
.
- Follow-Ups:
- Re: reinterpret_cast
- From: Slava M. Usov
- Re: reinterpret_cast
- References:
- Re: reinterpret_cast
- From: Carl Daniel [VC++ MVP]
- Re: reinterpret_cast
- Prev by Date: Re: distinguish between floppy & flashcards
- Next by Date: Re: Mutual Exclusion for shared Buffer b/n User and Kernel
- Previous by thread: Re: reinterpret_cast
- Next by thread: Re: reinterpret_cast
- Index(es):
Relevant Pages
|
Loading