casting - c++ union in multiple files -
i'm sorry long, little complicated explain.
we had hand in homework following program (much simplified here):
- some type of structure (class/struct) representing physical block of data (just char[1024])
- two types of logical partitioning of block
for example:
struct p { char[1024] } struct l1 { int num; char name[20]; } struct l2 { int num; char type[10]; char filler[400]; bool flag; }
the obvious thing me have union
union { p phy; l1 logi1; l2 logi2; }
but problem part of specification (the part cut out simplify it) physical stuff in separate file logical stuff.
so question is: there way add fields union (i assume not) or way have functions in 'physical' file accept 'logical' blocks , use them raw blocks?
i hope clear.
p.s. due , solved reinterpret_cast
. wondering if there more elegant way.
what can create 2 unions. long don't interchange them fine.
Comments
Post a Comment