When a project grows, it is common to split the code up into different source files. When this happens, the interface and implementation are generally separated. The interface is placed in a header file, which commonly has the same name as the source file and an .h file extension. This header file contains forward declarations for the source file entities that need to be accessible to other compilation units in the project. A compilation unit consists of a source file (.cpp) and any included header files (.h or .hpp).
29. Headers
Get C++20 Quick Syntax Reference: A Pocket Guide to the Language, APIs, and Library 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.