I'm attempting to read from a file a customer's name, id, and loan information. The file is setup like this:
Williams, Bill
567382910
380.86
Davidson, Chad
435435435
400.00
Basically, every time I come to a new name, the information is going to be placed into a new object of the Customer class. My problem is, I'm trying to read from the file but I'm not sure how to overload the operator correctly to read only 3 lines from the file like I want to and put them in the right place.
I create the customer and open the file here:
Menu::Menu()
{
Customer C;
ifstream myFile;
myFile.open("customer.txt");
while (myFile.good())
{
myFile >> C;
custList.insertList(C);
}
}
This is just what I have in my .cpp file for a Menu class. Here is my code (the tiny bit that I know how to do) for the overloaded operator in my .cpp file for the Customer class.
istream& operator >> (istream& is, const Customer& cust)
{
}
I'm not sure how to only get the three lines and place them into their respective places inside of a Customer which are:
string name
string id
float loanamount
If anyone could help me out with this I'd really appreciate it.