|
Boost Users : |
Subject: Re: [Boost-users] Derived class is not serialising/de-serialising...
From: kwanti (ngkwanti_at_[hidden])
Date: 2013-08-07 10:33:20
I think you need to serialize the derive object by base pointer.
e.g.:
void Communication::sendRequest(BaseClass* request) // change to pointer
here
{
// Open the file for write, and truncate.
std::ofstream file(getFilename().c_str(), std::ios::trunc);
// Use boost to serialize the object to the file.
boost::archive::binary_oarchive archive(file);
archive << request;
// Close the file.
file.close();
}
void Communication::receiveRequest(BaseClass* request) // change to
pointer here
{
// Open the file for read.
std::ifstream file(getFilename().c_str());
// Use boost to serialize the object from the file.
boost::archive::binary_iarchive archive(file);
archive >> request;
// Close the file.
file.close();
}
-- View this message in context: http://boost.2283326.n4.nabble.com/Derived-class-is-not-serialising-de-serialising-tp4650344p4650452.html Sent from the Boost - Users mailing list archive at Nabble.com.
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net