I have the following problem and I hope the great community can help me. If I have a class one:
class one
{
private:
int data;
public:
one();
void safe();
void load();
};
And then 2 derivative classes of class one:
class two: public one
{
private:
int data2;
public:
two();
safe();
load();
};
class three: public one
{
private:
int data3;
string data4;
public:
three();
void safe();
void load();
};
And now I have to store data in these classes. The object of the classes are stored in a List. And one Element of these List can be in this example one object of class two or class three. Now If I have to save the content of a list in a file I need to get data of data2
or If I have the other object I need data3
and data4
.
How can I check which derivate it is and how can I get the data of the objects? I mean that must be possible because they are both derivatives of one.