Creating the precompiled header

The code will use the C++ Standard Library to input and output via streams, so it will use the <iostream> header. The code will use the C++ string type to handle input, so it will use the <string> header. Finally, it accesses the C runtime time and date functions, so the code will use the <ctime> header. These are all standard headers that will not change while you develop the project, so they are good candidates for precompiling.

In Visual Studio create a C++ header file and add the following lines:

    #include <iostream>     #include <string>     #include <ctime>

Save the file as utils.h.

Now create a C++ source file and add a single line to include the header file you just created:

    #include ″utils.h″

Save this ...

Get Beginning C++ Programming 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.