mercredi 13 septembre 2017

Serializing/deserializing objects in C++

I'm working on a small project which requires objects to be serialized/deserialized in C++, we cant use any third party library.

class Person
{
    public:
        Person(){}
        void serialize()
        {
            // serialize current object state
        }
        bool deserialize()
        {
            // deserialize members
        }
    private:
        string name;
};

I want to know if it is possible to achieve below...

  • In case someone add another member to this class but forget to serialize/deserialize, he/she should get compile time error.

Secondly what are the best practices for serialization/deserialization of objects.

Aucun commentaire:

Enregistrer un commentaire