Please do not do this. Never.
Basically, you use the old style to distinguish a* from char* . This gives silently in reinterpret_cast between two unrelated types and is highly implementation dependent . You cannot rely on a basic memory layout: it can change for any reason (even when using the same compiler).
If your class contains pointers, you have no guarantee that the data they point to will still be (or just the same) when you reload your class.
If you want to provide a serialization mechanism, create your own serialize() and deserialize() functions (they can even be template functions, which you can then specialize, or just regular member functions, it doesn't really matter).
Of course, this requires a little more work, but for the sake of reliability. In addition, you can optimize the presentation of data according to any type of storage (stored on disk, sent to the network ...), and you can even change your class interface and still maintain compatibility with already serialized instances.
ereOn source share