-
Book Overview & Buying
-
Table Of Contents
The C++ Workshop
By :
We've come across this term a few times now, so let's look at what it means. A preprocessor directive is a statement that runs before our code is compiled. This is incredibly useful for a range of different things, from header files to selective code compilation.
One of the most common directives, #include, we've already looked at; it means "copy here." When the preprocess runs, it will literally copy and paste the contents of the included file in its place. This means that any functions, variables, classes, and so on defined in that header are now also accessible by the class containing the include directive.
There are two variations you'll see with this directive:
// Include example. // Version 1 - Generally for system files. #include <headerfile> // Version 2 - Generally for programmer files. #include "headerfile"
In Version 1, you're directing the preprocessor...