Re: Header files in c++
Header files are libraries which include prototypes of all functions used in C language
prototype is a line that you write at the beginning of any C program , it is like the
function deceleration except you add semi colon (; ) after it .
for example :
int line (void); // this is a prototype for a function named line .
the previous line must be written before the main function , or you will have an error message tells you : function line must have a prototype .
when do i have to write the prototype ?
a prototype in the head of a program is to tell the compiler that there is a function
in the code to be invoked . so it would be considered .
does this mean that any function you use have a prototype ? that is correct .
even functions like : printf , cout , scanf , getche, ...etc have prototypes .
these prototypes are in the header files so if you noticed you don't write them
again. so you have to include the header file you need in the program to be
compiled . i'll give you an example : printf function's prototype is in the header file
(stdio.h) so you have to include it in the program if you want to use printf function
cout prototypes is in (iostream.h) etc .
hope be usefull