Originally Posted by
laserlight
I suppose so, but in retrospect, the function template looks out of place. It does a very generic job: call the overloaded operator>> for T. In fact, it is so generic that it does not belong in your class, and perhaps is not needed at all. The very reason for a ReadFromFile() member function in the first place was to have interactive input from the user into the object, but this is no longer the case in your ReadFromFile function template.
Eish, now there am getting confused again or should i just make it a free function, then everything will be fine... Anyway, i have a quick question ..
Code:
void Rental::ReadNewDriverDetails(std::string* refNo)
{
std::string fname, sname, contact;
std::string IDNo;
system("cls");
std::cout << "\n \t\t\tÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»\n";
std::cout << " \t\t\tº DRIVER DETAILS º\n";
std::cout << " \t\t\t\314ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ\271";
std::cout << "\n\n\nEnter the following Driver's details\n\n";
std::cout << "\nFull Name : ";
std::in >> fname >> sname;
std::cout << "\nDriver's ID Number : ";
std::in >> IDNo;
*refNo = IDNo;
std::cout << "\nContact Number [ccc-ddd-dddd] : ";
std::in >> contact;
// Here's my question
driver.SetAddress( ReadNewAddress(driver.getAddress()) );
driver.SetDriverDetails(fname, sname, IDNo, contact);
}
Does that look fine ..
Code:
Address Rental::ReadNewAddress(Address address)
{
std::string fline, sline, sbb, city, cde;
system("cls");
std::cout << "\n \t\t\tÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»\n";
std::cout << " \t\t\tº PHYSICAL ADDRESS º\n";
std::cout << " \t\t\t\314ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ\271";
std::cout << "\n\n\nEnter physical address below ...";
std::cout << "\n\n1. First line : ";
std::cin >> fline;
std::cout << "\n2. Second line : ";
std::cin >> sline;
std::cout << "\n3. Third line : ";
std::cin >> sbb;
std::cout << "\n4. City : ";
std::cin >> city;
std::cout << "\n5. Code : ";
std::cin >> cde;
address.SetAddress(fline, sline, sbb, city, cde);
return address;
}
Reason am asking is if i use a reference as 'void Rental::ReadNewAddress(const Address& address) then i cant set the address ... Hence opted for return address ...