Hi I wonder, Is it necessary to use reinterpret_cast< char*> when reading from a binary file. Since I found that a explicit typecast worked as well e.g. (char*), sizeof(int).
+1
A:
both reinterpret_cast and the C-style explicit cast do exactly the same thing in your context. I prefer reinterpret_cast as it makes the nastiness more explicit when reading the code.
Elemental
2010-10-02 09:03:12
so there are some cases that you have to use reinterpret_cast? I haven't tried reading a binary file containing struct. But will that do any difference if I use c-style explicit cast instead of reinterpret_cast?
starcorn
2010-10-02 09:05:41
Old-style cast may correspond to static_cast, reinterpret_cast or const_cast, or even a combination of them - so it is slightly stronger than even reinterpret_cast but in general they are very similair
Elemental
2010-10-02 11:51:49