Tools.h++ Manual

104011 Tandem Computers Incorporated 17-21
17
Program output:
Bus number 1 has been restored; its driver is Kesey.
It has 4 customers and 2 passengers.
{
Bus theBus(1, "Kesey");
theBus.addPassenger("Frank");
theBus.addPassenger("Paula");
theBus.addCustomer("Dan");
theBus.addCustomer("Chris");
{
ofstream f("bus.str");
RWpostream stream(f);
stream << theBus; // Persist theBus to an ASCII
stream
}
{
ifstream f("bus.str");
RWpistream stream(f);
Bus* newBus;
stream >> newBus; // Restore it from an ASCII
stream
cout << "Bus number " << newBus->number()
<< " has been restored; its driver is " << newBus->driver()
<< ".\n";
cout << "It has " << newBus->customers() << " customers and "
<< newBus->passengers() << " passengers.\n\n";
delete newBus;
}
return 0;
}