Skip to content

Commit 7b9a53f

Browse files
author
Michael McLeod
committed
Clarifying why headers are useful
1 parent 4165f1b commit 7b9a53f

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

01projects/sec03MultipleFiles.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ g++ -o test_f main.cpp function.cpp
175175

176176
## Header Files
177177

178-
Forward declarations for functions are helpful, but they can still clutter up our code if we are making use of large numbers of functions! Instead, we put these declarations in **header files**, which usually end in `.h` or `.hpp`. We use `#include` to add header files to a `.cpp` file: this allows the file to get the declaration from the header file. The definitions are not kept in the header file, they are in a separate `.cpp` file.
178+
Forward declarations for functions are helpful, but they can still clutter up our code if we are making use of large numbers of functions. We would also need to rewrite these forward declarations for _every_ source file that needs to use them! Instead, we put these declarations in **header files**, which usually end in `.h` or `.hpp`. We use `#include` to add header files to a `.cpp` file: this allows the file to get all the declaration from the header file. The definitions are not kept in the header file, they are in a separate `.cpp` file so that they can be compiled separately.
179179

180180
In this case the files look as follows:
181181

0 commit comments

Comments
 (0)