Well, this is not C++ with objects on the stack which can be "sliced"...
Some alternatives:
1. study the documentation, it should be able to serialize a polymorphic collection, maybe requires more work on your part.
2. "brute force" solution (I consider it ugly): build a conversion operator or a constructor able to convert an AdminPerson back to Person. Iterate the resulting collection and replace AdminPerson instances with newly created copies of Person.
3. My previous post was already explaining you how to remove the inheritance hierarchy and add Admin part as a separate object in an one-to-one relationship, so your collection will be only of Person objects.
I tend to preffer 1., try to search for info on how to serialize a polymorphic collection.
HTH,
Radu
|