Read class objects from file c++
<p>I need to read class objects from file, but I don't know how.</p>

<p>Here I have a class "People"</p>

<pre><code>class People{
public:

string name;
string surname;
int years;
private:

People(string a, string b, int c):
name(a),surname(b),years(c){}
};
</code></pre>

<p>Now I would like to read peoples from .txt file and store them to objects of a class People.</p>

<p>For instance, this is how my .txt file looks like:</p>

<pre><code>John Snow 32
Arya Stark 19
Hodor Hodor 55
Ned Stark 00
</code></pre>

<p>I think the best way to do this would be to create array of 4 objects. I need to read word by word and line after line, if I assume correctly but I don't know how...</p>