I'm reading in a file of user information in the format:
1 David Davidson: 64 Zoo Lane
2 Homer Simpson: 123 Fake Street, Springfield
3 Craig Boone: Presidential Suite, Lucky 38, New Vegas
I want to store the information in a class called Borrower with fields for their ID number, name, and address so I've overloaded the >> operator as follows:
istream& operator>>(istream& in, Borrower& b){
in >> b.idNumber;
std::getline(in, b.name, ':');
in.ignore(1);
in >> b.address;
return in;
}
and I'm trying to use it in main.cpp as follows:
ifstream fileUsers;
fileUsers.open("users.txt");
if (!fileUsers.is_open()){
exit(EXIT_FAILURE);
}
Borrower b();
while (fileUsers.good()){
fileUsers >> b;
cout << b;
}
but i'm getting 'ambiguous overload for operator >>' errors and 'no known conversion from 'Borrower()' to 'std::basic_istream....' and I don't know what to do, please help