ostream& operator <<(ostream& osObject, const storageRentals& rentals)
{
osObject << rentals.summaryReport();
return osObject;
}
Your storage report implicitely is always streamed to cout. Imagine someone calling your function this way and having the rentals on cout instead of the file.
fstream fs("out.txt");
storageRentals rentals;
fs << rentals;
Why don't you stream your class like this:
ostream& operator <<(ostream& osObject, const storageRentals& rentals)
{
for (int count = 0; count < 8; count++) {
osObject << "Unit: " << count + 1 << " " << rentals.stoUnits[count] << endl;
}
return osObject;
}
If the stoUnits member is private you need to make the stream function a friend of your storage class.
friend ostream& operator<<(ostream& osObject, const storageRentals& rentals);