
Loïc Joly wrote:
Jeff Garland a écrit :
Oliver is correct -- serialization does not require default constructors for the types. It does require a constructed object prior to reading in the data.
Yes, you are right. My mistake.
What I meant is that for deserialisation, you still have a two phases construction: First, build your object with any mean available (if your object have only constructors with non-default parameters, this will probably imply building them with dummy parameters), then, in a second phase, override the member values by the serialized version.
Yep. So in some case this is easy and in some cases not. But in some of the 'hard cases' you wouldn't typically serialize the objects anyway. I'd argue the EventLogger case is not the sort of object that would ever by serialized. This is compared to dates, times, strings, collections, and other objects that will frequently be serialized.
In my C++ code, when I use uninitialized or "dummy-initialized" object, this is most of the time because I'm going to read a stream into the object, or deserialize the object.
Yep. Jeff