0

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
{
public:
    BREAD();~BREAD();
    //lame example
    std::vector<string> selectIngredient(std::vector<FLOUR>grocery);

};
#endif

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

Edited by pritaeas: Moved.

3
Contributors
2
Replies
21
Views
2 Years
Discussion Span
Last Post by mike_2000_17
0

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

0

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.).

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.