Saving the Tape Between Sessions

So far, all of the calculator's actions have been based on your input, and when you stop the calculator, all of the work you've entered into it has been lost. This is because program variables only retain their content while the program is running. Their collected content is often referred to as the program's state.

Most computers have a file system, whose purpose is to retain data between program runs. And every programming language has a way to put data into files in the file system and get data from them. C++ uses a special kind of stream—the fstream (file stream), which is similar to cin and cout—for that purpose.

fstreams

Unlike cin and cout, the file stream #include<fstream> does not provide variables representing ...

Get SAMS Teach Yourself C++ in 10 Minutes SECOND EDITION now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.