I want to Serialize a class that’s part of inheritance. I’m using C++98 and no 3rd party libraries. Here is my class structure:
class Base{
public:
virtual RunMe()=0;
};
class Derived: public Base{
virtual RunMe(){
std::cout << "I am running << std::endl;
}
};
I am able to Serialize a basic class using ofstream and fstream, via friend technique. But I can’t figure out how to implement Serialization in case where my Base class has a pure virtual function.
Add serialization support methods to your base class.
Your child classes would first call the base class support methods, then their own.