I am trying to read from a file, but after I read 1 item, I get no more. (eof maybe).
I am trying to serialize my class (and its subclasses) by overiding the >>/<< and ifstream and ofstream. The ofstream part works fine and my file is built properly. When I read it back in, I only get the first item, and the rest are null,
All I get is the first name, all other fields are NULL.Code://AddressBook.cpp overload ifstream& operator >>(ifstream &infile, CAddressBook *entry) { cout << "Loading in a new AddressBook object from the file." << endl; infile >> entry->m_contact; cout << "Done loading in a new AddressBook object from the file." << endl; } //Contact.cpp overload ifstream& operator >>(ifstream &infile, CContact *contact) { cout << "Reading in Contact info." << endl; infile >> contact->m_fname; cout << "I read first name as :" << contact->m_fname << endl; infile >> contact->m_lname; cout << "I read last name as :" << contact->m_lname << endl; infile >> contact->m_pnumber; infile >> contact->m_email; cout << "I read email as :" << contact->m_email << endl; cout << "Done reading in Contact info." << endl; } //PhoneNum.cpp overload ifstream& operator >>(ifstream &infile, CPhoneNum *pnum) { cout << "Reading in the phonenumber." << endl; infile >> pnum->m_areacode; cout << "Read areacode as:" << pnum->m_areacode << endl; infile >> pnum->m_prefix; cout << "Read prefix as:" << pnum->m_prefix << endl; infile >> pnum->m_suffix; cout << "Read suffix as:" << pnum->m_suffix << endl; cout << "Done reading in the phonenumber." << endl; }
I added all the obnoxios couts to try and debug what was happening. Any ideas?



LinkBack URL
About LinkBacks


