-
Understanding Headers
I'm currently in the process of learning c++ and I am trying to get a better understanding of whats going on... I was wondering if it is possible to program anything useful without using headers, and also... what is inside these headers, i have a vague understanding but its still doesn't quite all add up yet.
-
Well the headers just contain prototypes and constants and the like, if you really want to see what the stuff in the header does how it does it, go take a peak at the GCC runtime library source.
-
Open one up and take a peek. They're just text files with a different (or no) extension. They mostly contain function prototypes, #define statements, struct/class declarations and in the case of templates (usually) actual code. This information is primarily needed by the compiler to perform it's job of type checking. An #include statement for a given header informs the compiler to take the contents of that file and dump it into the source file (copy and paste basically) during the preprocessing stages and prior to the actual compilation step.