Popular Google Pages:
◕ Bengali Story writing competition. More..
This article is regarding Directive and Header File of C++.
Last updated on: 24th November 2016.
Let we have a code #include <iostream>.
Here #include is called Directive. This is called Directive because it directs the compiler to do some work.
In this case it directs the compiler
"To insert the iostream file's contents into the program source file before the compiler starts compiling."
The iostream file is called the Header File. The iostream file is a part of the standard C++ library.
This Header File contents the codes or definitions that are necessary to run the C++ Input & Output Statements.
If we didn't include the iostream file, the program will not run. Because the output statements of the program depends on some of the definitions of this iostream file.
There are so many numbers of Header Files in C++.
We can write both
#include <<iostream> &
Then what is the difference between them?
The main and only important difference between these two is that
"It tells the compiler where the file is! On other word it tells the compiler the location of the file."
◕ < >
We should use this angle brackets for only the Standard Library and System Header Files like iostream which is provided with the system.
◕ " "
We should use quotes to include other Header Files which we created by our own. These type of Header Files we generally keep in the same directory or folder as our source files.
If we move all our #include Header Files ( Which we have created ) in a separate area, then we have to inform the compiler about that particular separate location.
◕ As a summery and in a simple word we can say, if we use < > then the compiler directly and only search that file in the Standard Header Files .
And if we use " " then the compiler first search that file in our Source Files and then search it in Standard Header Files .
So if we have our own Header File, then we have to put this between the quotes (" "), otherwise the compiler will not find the file at all.
Top of the page