D
Dom Bannon
Is this ever possible?
More specifically, I have a simple disk record which is, say, 64 bytes
long. Currently, I have a class which defines various members
corresponding to the fields in this record, and the class is
responsible for writing itself to/reading itself from disk.
This is fine, but it's inefficient. Ideally, I'd like to fread in 64
bytes directly on top of a class instance, or fwrite out 64 bytes from
the address of the class, pretending that it's a C struct.
I can clearly get this to work in simple cases where I use a member
address instead of a class address - for example, my class might
contains one member, which is a 64-byte array, or it might contain a
union, one element of which is a 64-byte array. Would this work for
more complex cases? Presumably there's no guarantee that the address
of a class is the address of it's first member?
Thanks -
Dom
More specifically, I have a simple disk record which is, say, 64 bytes
long. Currently, I have a class which defines various members
corresponding to the fields in this record, and the class is
responsible for writing itself to/reading itself from disk.
This is fine, but it's inefficient. Ideally, I'd like to fread in 64
bytes directly on top of a class instance, or fwrite out 64 bytes from
the address of the class, pretending that it's a C struct.
I can clearly get this to work in simple cases where I use a member
address instead of a class address - for example, my class might
contains one member, which is a 64-byte array, or it might contain a
union, one element of which is a 64-byte array. Would this work for
more complex cases? Presumably there's no guarantee that the address
of a class is the address of it's first member?
Thanks -
Dom