1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
|
istream &operator>> (istream &is, Person &pers)
{
Name nam;
string str;
Address addr;
string persNr;
int skoNr = 0;
getline(is, str, DELIM);
nam.setFirstName(str);
getline(is, str, DELIM);
nam.setLastName(str);
// assign this to pers
pers.setName(nam);
getline(is, str, DELIM);
addr.setStreet(str);
getline(is, str, DELIM);
addr.setPostNr(str);
getline(is, str, DELIM);
addr.setTown(str);
// assign this address to pers
pers.setAddress(addr);
getline(is, str, DELIM);
pers.setPersNr(persNr);
// TAKE OFF THESE LINES
//cin >> skoNr;
//pers.setSkoNr(skoNr);
//cin.get();
// REPLACE WITH THESE with #include <cstdlib> for atoi
getline(is, str);
int skonr = atoi(str.c_str()); // converts the string to int
pers.setSkoNr(skonr);
return is;
}
|