I'm not clear as to the purpose of these preproccer directives in all my header files
#ifndef _FILENAME_HPP_
#define _FILENAME_HPP_
also is it neccary to include <iostream> in my header file if it is included in my main file?
I'm not clear as to the purpose of these preproccer directives in all my header files
#ifndef _FILENAME_HPP_
#define _FILENAME_HPP_
also is it neccary to include <iostream> in my header file if it is included in my main file?
by using the #ifndef and #define, you will prevent the compiler from linking the header twice, which will cause you an error. sample:
#ifndef _HELLO_H
#define _HELLO_H
#include <stdio.h>
#include <iostream.h>
int something;
#endif
#ifndef _HELLO_H
#define _HELLO_H
// your code goes here...
#endif
this is a preprocessor directive that is used when a file Hello.h is included within another file....especially when Hello.h is used by many different files, the purpose of this is NOT to have multiple declarations of Hello.h......
those statements mea: if ... hello.h is not yet defined within the program (or a file system) ....then define it (write it in)......at the end you need... #endif.....to end your if statement
Regards,
matheo917
If you call a function from <iostream> anywhere in the *.cpp file associated with the header file, then yes you do need to include it.Originally posted by rip1968
also is it neccary to include <iostream> in my header file if it is included in my main file?
Last edited by jdinger; 05-04-2002 at 08:22 AM.
Thanks to you all for clearing these points up.