Inclusion and Inclusion Guards

You will create projects with many different files. You will probably organize your directories so that each class has its own header file (.HPP) with the class declaration, and its own implementation file (.CPP) with the source code for the class methods.

Your main() function will be in its own .CPP file, and all the .CPP files will be compiled into .OBJ files, which will then be linked together into a single program by the linker.

Because your programs will use methods from many classes, many header files will be included in each file. Also, header files often need to include one another. For example, the header file for a derived class's declaration must include the header file for its base class.

Imagine that ...

Get Sams Teach Yourself C++ in 24 Hours, Third 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.