Changing the project

Now that you have the basic project structure, with a makefile you can make changes to the files and be reassured that, when the project is rebuilt, only the files that have changed will be compiled. To illustrate this, change the print_name function in name.cpp to ask for your name in a more polite way. Change the first line in the function body as highlighted here:

    void print_name()     {        std::cout << "Please type your first name and press [Enter] ";         std::string name;

Save the file and then run the make utility. This time, only the name.cpp source file is compiled, and the resulting file, name.obj, is linked with the existing object files.

Now change the name.h header file and add a comment in the file:

 // More polite ...

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.