www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - How to read a C++ class from file into memory

I am coming from Python to D, so forgive my limited C/C++ knowledge.

What is the idiomatic way to read a heterogeneous binary structure in D? 

In my C++ book, it shows examples of defining a class or struct with the
appropriate types and then passing a pointer to this class to fread().

However, in Java or Python I could just read the types directly from a binary
stream (including the padding bytes associated with the structure on disk).

How should I do this in D?

I did see this post:


Note that I ultimately want to store these data back into classes where I can
work with it.


Mar 22 2007