A
Andrea Crotti
Supposing I have a class with many objects which are also of class
Serializable.
I've been wondering for a long time how I can iterate over them, and
maybe I found a solution:
auto_ptr<Serializable> fields[NUM_FIELDS];
and then during initialization do
fields[0] = auto_ptr<Serializable>(¤tLocation);
fields[1] = auto_ptr<Serializable>(&address);
and supposing they all have the method "check" I could do
for (int i = 0; i < NUM_FIELDS; ++i)
if (! (fields->check()))
return false;
return true;
for example, which looks quite nice.
Does it make sense?
Maybe I should give completely to auto_ptr the control?
And also I tried first with a vector but it doesn't work, I read on the
internet something but I really didn't get why
vector<auto_ptr<Serializable> > is not digested by C++...
Serializable.
I've been wondering for a long time how I can iterate over them, and
maybe I found a solution:
auto_ptr<Serializable> fields[NUM_FIELDS];
and then during initialization do
fields[0] = auto_ptr<Serializable>(¤tLocation);
fields[1] = auto_ptr<Serializable>(&address);
and supposing they all have the method "check" I could do
for (int i = 0; i < NUM_FIELDS; ++i)
if (! (fields->check()))
return false;
return true;
for example, which looks quite nice.
Does it make sense?
Maybe I should give completely to auto_ptr the control?
And also I tried first with a vector but it doesn't work, I read on the
internet something but I really didn't get why
vector<auto_ptr<Serializable> > is not digested by C++...