Question: Object-Oriented Programming C++ - I have to output my program to a file called sim.txt. My simulation is a function obviously so I'm not able

Object-Oriented Programming C++ - I have to output my program to a file called "sim.txt". My simulation is a function obviously so I'm not able to do a thing like:

std::ofstream outputFile;

outputFile.open("sim.txt", std::ios::out);

outputFile << runSimulation(franchises, days);

outputFile.close();

Because I then get the error that is that the operator << does not recognize an ofstream to a void function. runSimulation also has another print function nested within it called printRundown that runSimulation calls once per day.

Signatures for printRundown and runSimulation:

void runSimulation(std::vector &franchises, int days);

void printRundown(const std::vector &franchises);

I'd prefer you to overload the operator << to make it happen, but if there is a way that you know of that is easier then please do go with that. I'm having a hard time figuring this problem out. Thanks

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!