From: rameysb (ramey_at_[hidden])
Date: 2002-02-28 15:51:30


> > The proper way to handle multple base classes is:
> >
> > void C:save(::boost::oarchive &ar) const
> > {
> > // serialize the B1 data
> > ar << * static_voi<(B1 *>(this);
> >
> > // serialize the B2 data
> > ar << * static_voi<(B2 *>(this);
> >
> > // serialize the C member variables
> > ar << c;
> > }
> >
> > Robert Ramey
> >

> That doesn't work as such. If C::save is not an override of a
virtual
> function, C::save will never be called if it is only referenced
through
> pointers to its B1 and B2 base classes. If neither B1 nor B2 has
made
its
> save function virtual, there is no way that B1 or B2 could possibly
know
> that it's part of a C. If B1 and B2 have virtual save functions
that
are
> overriden by C, the program will lock up in an infinite loop since
C::save's
> calls to save its B1 and B2 base classes will result in calling
itself.

> -- Noah

This case is discussed in the documentation. for such a case
one more thing will need to be added to each the derived class

C::C()
{
    // if the program is going to create an archive that
    // serializes and instance of this class through a base
    // class pointer
    serialize<C>::save_register();
    // if the program is going to create an archive that
    // serializes and instance of this class through a base
    // class pointer
   serialize<C>::load_register();
}

This resolves your concern. It is discussed in the documentation.
Its usage is demonstrated in demo.cpp

Robert Ramey