I can serialize an object if it's class definition has attributes.
So if I have an object whose class does not have attributes, do I serialize the attributes importedi in it's class definition?

For example; suppose I have the following class,

#ifndef BREAD_H
#define BREAD_H
#include "EGGS.h";
#include "FLOUR.h";
class BREAD
    //lame example
    std::vector<string> selectIngredient(std::vector<FLOUR>grocery);


How would I go about serializing attributes defined in the FLOUR.h class if incase I have to?
Thanks in advance.

Recommended Answers

All 2 Replies

There's no data there to store. Every BREAD object is identical to every other BREAD object. There's nothing to serialise.

Like Moschops said, if there is nothing to store, there is nothing to store. Of course, depending on your serialization method, you might have to store some header information even if the "body" is empty (e.g., in my serialization formats, I usually store a version number (for forward and backward compatibility), a class GUID number, an object ID number (for simple dictionary-based compression), etc.).

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.