When we include a header file, we must specify the full name of the file, including the filename extension .h. You may wonder therefore when we include a header file from the standard library, why do we use the first of the following two directives:
#include <iostream> #include <iostream.h>
If you have ever looked through old examples from C++, you will see that some files do indeed use the second of these directives.
In C++90, namespaces were added to the C++ programming language, a decision was made to move all standard library functions to the std:: namespace. Unfortunately, this would result in all older pre-namespace programs to fail. Thus, <iostream.h> says get the old library (which is no longer being updated, and which should never be used) while <iostream> indicates that it should use the current library. Thus, in older programs, this will work:
#include <iostream.h> int main(); int main() { // No namespaces used here cout << "Good bye world!" << endl; return 0; }
The same goes for libraries such as cmath.h, vector.h, etc.
In general, if you see any library inclusion:
#include <library_name.h>
your first thought should be, "Oh, that's quaint." If you try to modify it, however, you may be using features implemented in the newer and maintained versions of the library, while the older non-namespace versions have been frozen in time. Additionally, bug fixes are not retroactively applied to the older versions of the library, so if you were to use the old libraries, you may run into issues that have since been fixed in current libraries.