I can't understand the concept of reinterpret_cast and static_ cast. Can anyone please explain in easy method using ASCII Art or something like that..
Asked
Active
Viewed 84 times
-5
-
What have you read about them so far? – Christian Hackl May 03 '14 at 13:17
1 Answers
1
IDK about art; but reinterpret_cast
can only be used with a pointer or reference. It means that you intend to treat the memory pointed to by a pointer to T
as containing an object of type U
. If it does not contain such an object (as defined by the strict-aliasing rules in the C++ standard) then it is undefined behaviour.
static_cast
performs a conversion. With a pointer or a reference, it is similar to reinterpret_cast
, but it enforces that T
and U
must be compatible types. With an object type, it looks for a defined conversion between those two object types.

M.M
- 138,810
- 21
- 208
- 365
-
I saw somewhere it was used in reading/writing binary files what is its purpose there ? Kindly explain with easy examples – Kashiii May 04 '14 at 01:36