Writing Classes to File

Jeremy Jeremy_member at pathlink.com
Mon May 8 09:32:16 PDT 2006


Is there a way I can just write a whole class to a file?

For example, why can't I do:

file.writeExact(someClass, someClass.sizeof);

This seems to just write 4 bytes, which must be the pointer.

The compiler complains when I do this:

file.writeExact(*someClass, (*someClass).sizeof);

Saying that '*' is only used infront of pointers -- but aren't class always
represented with pointers?

Anyway, I want to save a class to file, so I can load it back. I was hoping
there was a way to do this without having to write/read each element of the
class seperately.





More information about the Digitalmars-d mailing list