I have a class like this:
class C {
protected:
std::string data1;
int data2;
int data3;
std::string data4;
public:
C() {};
C(C const *obj) {};
virtual ~C() {};
};
And another class that is a list of C objects like this:
class CList{
private:
size_t size;
C** clist;
public:
CList();
~CList();
What I would like to do is if I have a list with for example 3 C objects, I would like to write the datas to a .txt file so it will look like this: "data1 data2 data3 data4\n data1 data2 data3 data4\n ...." And also if I already have a few saved objects in the .txt file, how can I read them from the file and make a list from them? I know there's a bunch of questions regarding this problem, but I couldn't use them successfully to make mine functional. Do I have to overload the >>, << operators, and if so, how should I do that?