Writing Classes to File

BCS BCS at pathlink.com
Tue May 9 09:33:41 PDT 2006


Chad J wrote:
[...]
> 
> Also, beware the object reference...
> 
> class Mobile
> {
>    struct fields
>    {
>        int x, y;
>        int health;
> 
>        char[] name;           // <---   There be monsters here!
>        Container backpack;    // <---
>    }
>    fields myVars;
[...]

> For handling the references, BCS, did you come up with something 
> different by any chance?

I mentioned it a few posts back but to summarize, reference items were 
dumper to the file first (after recording the current file location) and 
then file pointers were used in the parent object. This has the odd 
effect that children end up in the file first but oh well. To help find 
things I put a header at the start of the file (to begin with it had 
dummy values) and then when I knew where things ended up, I overwrote 
the header.

I have a linked list example I can post if anyone is interested but it 
will have to wait till Monday (I'm books until then).



More information about the Digitalmars-d mailing list