Reading & creating an object from txt file
<p>I have the fallowing function and i can't get it why it doesn't works. After saving the data is saved right but when reading it, it doesn't read the int parts. </p>

<pre><code>void StudentRepository::loadStudents(){
    ifstream fl;
    fl.open("studs.txt");
    Student st("",0,0);
    string str,s;
    stringstream ss;
    int i;
    int loc;
    if(fl.is_open()){
        while(!(fl.eof())){
            getline(fl,str);
            loc = str.find(",");
            ss &lt;&lt; str.substr(0,loc);
            s = ss.str();
            st.setName(s);
            str.erase(0,loc);
            loc = str.find(",");
            ss &lt;&lt; str.substr(0,loc);
            ss &gt;&gt; i;
            st.setId(i);
            str.erase(0,loc);
            ss &gt;&gt; i;
            st.setGroup(i);
            students.push_back(st);

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

<p>eDIT:</p>

<pre><code>class Student {
private:
    string name;
    int ID;
    int group;



public:
Student(string name, int id, int gr ):name(name),ID(id),group(gr){}

void setId(int value)       {group = value;}
void setGroup(int value)    {ID = value;}
void setName(string value)  {name = value;}
int getGroup()              const{return group;}
int getID()              const{return ID;}
    string getName()            const{return name;}

    friend ostream&amp; operator &lt;&lt; (ostream&amp; out, const Student&amp; student)
    {
        out &lt;&lt; student.name &lt;&lt; " " &lt;&lt; student.ID &lt;&lt; " " &lt;&lt; student.group &lt;&lt;endl;
        return out;
    }
};
</code></pre>

<p>file:(at print all int's are 0 as I initializate the object in the load function)</p>

<pre><code>maier tsdar,2,0
staedfsgu aldasn,0,3
pdasdp aasdela,323,23
marsdaciu baleen,234,4534
madsd,234,2345
</code></pre>
