Hmmm - it looks like ASTNode might not be polymorphic - it doesn't seem
tohave a virtual function defined.
Try the following change:
"Juan Quiroz" wrote in message
news:f4e027970605011410p207777c1m1abef4f5771acc07@mail.gmail.com...
I am trying to serialize a vector of polymorphic pointers. My code looks as
follows:
class ASTNode{
...
protected:
vector children;
string name;
string type;
private:
// Code for serialization
friend class boost::serialization::access;
template<class Archive>
void serialize(Archive & ar, unsigned int version)
{
ar & name;
ar & type;
ar & children;
}
virtual ~ASTNode(); // <== try adding this in!
}
class ASTNode2: public ASTNode{
...
private:
// Code for serialization
friend class boost::serialization::access;
template<class Archive>
void serialize(Archive & ar, unsigned int version)
{
// serialize base class information
ar & boost::serialization::base_object<ASTNode>(*this);
}
// End code for serialization
}
I use the vector "children" to hold pointers to both base and derived
objects. I have tried registering the derived classes at the top of the
serialize function call, with the use of
ar.register(static_cast(NULL)). I have also tried using the
BOOST_CLASS_EXPORT_GUID macro to register the classes in main. Yet, I still
get a unregistered class exception. Any guidance would be greatly
appreciated.
_______________________________________________
Boost-users mailing list
Boost-users@lists.boost.org
http://lists.boost.org/mailman/listinfo.cgi/boost-users