reinterpret cast - C++ reinterpret_cast -
I do not know why this simple code is not working Can someone explain me?
int main () {const char * c = "ret"; Unsigned four GOK_UINT8; Type Kifa GOK_UINT8 * pGOK_UINT8; Const pGOK_UINT8 y = reinterpret_cast & lt; Const GOK_UINT8 * & gt; (C); Return 0; }
Can anyone tell me why the Reentrip_cast should not work?
Thank you, Gokul.
Can anyone tell me why reinterpret_cast should not work?
AFAICS, reinterpret_cast
should work fine, but the assignment should cause an error.
This is because const GOK_UINT8 *
a non- const
indicator const
GOK_UINT8
objects , While a const pGOK_UINT8
is a const
indicator for non- const
objects.
Protects the specified object in the past, indicating the latter item, if the assignment is allowed, then you can change the object to avoid changing the const GOK_UINT8 *
Is for
Note that typedef
ad points behave oddly. C ++: A const
saves its left side, unless it is, unless the strange announcement of const
is due to syntax (C and so on) anything, then it saves its right. in T const
and T const *
, type object is T
while the T * const
indicator of an object is protected by T
if you have
typed TTT;
Then TPtr const
again creates the const
then const TPtr
does a The typedef
ad pointers indicates either the const
or the non- const
objects, you can not change it if you type the const
You can not bring around TPtr
and expect that the pointer is referenced for the object's protection.
(BTW, this is why STL classes have to define both a iterator
and const_iterator
.)
Comments
Post a Comment