#include

So I am self teaching myself c++ and I am following this tutorial and it just said to put these, and I do every time and I know they are needed, but what do they do?
example:
#include <iostream>
#include <stream>
etc..
The are directives to the preprocessor.
http://cplusplus.com/doc/tutorial/preprocessor/
It instructs the preprocessor to find the file you have specified and copy its contents where the #include is. Here you are using them to go get the contents of some language header files and copy them into your program.
#include <someFileName>

the # tells the compiler to do something before it actually compiles your code.

include is the pre-processor command. It tells us that we are going to insert the entire contents of another file to this location here.

<> tells us that the file is located in a path included by the project. Ussually this just points to a bunch of default headers that your compiler supports (windows/linux headers, c headers, iostream, etc). The other option is to put the filename in double-quotes which will search for files in the same directory as the current file.

someFileName this is the file that will be included.
Last edited on
Topic archived. No new replies allowed.