I made a class student
class student
{
private:
string ID;
string name;
int age;
public:
....
};
I want to get values from user and put it in a map so I created an Operator>> Overloading
istream& operator>> (istream& in, student person){
string newID;
string newname;
int newage;
return in;
}
and so when it goes to the cin part
student person;
cin>>person;
when it adds person to the data map it calls for values from the default constructor and not the cin
What to do?
The operator needs to take the second argument by reference:
Otherwise the changes you make to
personnever make it out ofoperator>>().