Originally Posted by
tabstop
Right. (This is the MakeNewContract-or-whatever function I suggested earlier.) I would read in after each prompt, rather than trying to get a whole bunch of stuff at the end. And then you do contract.date(SetDate(getCurrentTime())) and you're done. (Edit: Or do I mean contract.date.SetDate(getCurrentTime())? I got lost a little bit there, I think.)
prompt for each in this function?
Code:
std::istream& operator >> (std::istream& in, Contract& contract)
{
std::string contractID;
std::string rentalType;
unsigned carReg;
char carGrp;
Date iDate;
in >> contractID;
in >> carReg;
in >> carGrp;
in >> rentalType;
in >> iDate;
contract.SetContractDetails(iDate, carReg, rentalType, contractID, carGrp);
return in;
}
Well, i guess then if i do that definitely need two separate functions for readin from user and file ... Which i was trying to avoid.. I prefer a code which can be reused ... Read() should cater for both keyboard & file ... If fact, if i do this indata >> Contract, how would it know if i'm calling the keyboard inout rather than the file input? will it decided based on the indata stream type?
Code:
ifstream indata;
istream indata;
istream& operator >> (istream& indata, Contract& contract)
{
...
}
how would this function decide between the two streams?
[/code]