+ 6
It was in the earlier version of C++ compliers that a header file should have a .h extension such as <iostream.h> but in the newer version of C++ compliers , you can also attach header files without .h extension . Older versions of compliers don't compile them i.e the files without .h extension. The #include <foo.h> was common in C++ code prior to the C++ standard. The standard changed it to #include <foo>with everything from the header placed in the std namespace.There is no magic going on, the first looks for a file called 'foo.h' and the second for a file called 'foo'. They are two different files in the file system. The standard just changed the name of the file that should be included. In most compilers the old headers are still there for backwards compatibility (and compatibility with C), but modern C++ programs that want to follow the standard should not use them. In the case of standard C headers, the C++ versions have a c at the beginning, so the C header. Therefore, #include <stdlib.h> becomes #include <cstdlib>
8th Mar 2018, 4:57 AM
Akash Pal
Akash Pal - avatar