Build Class object from txt file line
<p>I have the following code and I want to build an object. How could I do it? Any ideas? The class is of type {sting,int,int}.</p>

<p>code:</p>

<pre><code>void StudentRepository::loadStudents(){
    ifstream fl;
    fl.open("studs.txt");
    Student A();
    if(fl.is_open()){
        while(!(fl.eof())){
            getline(???); //i dont knwo houw coudl i limit what i want were...

        }
    }
    else{
        cout&lt;&lt;"~~~ File couldn't be open! ~~~"&lt;&lt;endl;
    }
}
</code></pre>

<p>Save to file funcntion:</p>

<pre><code>void StudentRepository::saveStudents(){
    ofstream fl;
    fl.open("studs.txt");
    if(fl.is_open()){
        for(unsigned i=0; i&lt;students.size(); i++){
            fl&lt;&lt;students[i].getName();
            fl&lt;&lt;",";
            fl&lt;&lt;students[i].getID();
            fl&lt;&lt;",";
            fl&lt;&lt;students[i].getGroup();
            fl&lt;&lt;","&lt;&lt;endl;
        }
    }
    else{
    cout&lt;&lt;"~~~ File couldn't be open! ~~~"&lt;&lt;endl;
}
</code></pre>

<p>I tried to implement some limits but that is not working... How canI do this?</p>

<p>Initially I just wrote the object to file but it is harder to get them back to the object....
File content:</p>

<pre><code>maier ewew 123 232
tudor efsw 13 2323
</code></pre>
