for(int i = 0; i < 1000; i++)
{
msg[i].convertToString(messageID);
getline(inFile,data);
msg[i].setDate(data);
getline(inFile,data);
msg[i].setSender(data);
getline(inFile,data);
msg[i].setRecipient(data);
getline(inFile,data);
msg[i].setBody(data);
}
Line 3. There is nothing to convert, since you've never actually read
messageID in from the file, have you? What conversion is required, by the way? You store messageID as an integer, but you call a function called
convertToString , which takes an integer and returns a string. You have this as input:
Read it in as a string, then pass it to a function that returns an integer, not vice versa, because you want the 12 and you want to throw out the part before the 12. So you need a function that parses a string and extracts the integer at the end of it:
int Message::ExtractIntegerFromString (string input);
After doing that, this could be the code in your loop to replace line 3 above.
int messageid;
string input;
inFile >> input;
int messageid = msg[i].ExtractIntegerFromString (input);
msg[i].setMessageID (messageid);
You'll need to write the
setMessageID function. I don't see it anywhere.
Last edited by VernonDozier; Nov 29th, 2008 at 10:46 pm.