© Mikael Olsson 2020
M. OlssonC++20 Quick Syntax Referencehttps://doi.org/10.1007/978-1-4842-5995-5_29

29. Headers

Mikael Olsson1 
Hammarland, Finland

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).

Why Use Headers

C++ requires everything to be declared before it can be used. It ...

Get C++20 Quick Syntax Reference: A Pocket Guide to the Language, APIs, and Library now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.