I have always seen people write
class.h
#ifndef CLASS_H
#define CLASS_H
//blah blah blah
#endif
The question is, why don\'t they
It doesn't - at least during the compilation phase.
The translation of a c++ program from source code to machine code is performed in three phases:
class.h is inserted in place of the line #include "class.h. Since you might be includein your header file in several places, the #ifndef clauses avoid duplicate declaration-errors, since the preprocessor directive is undefined only the first time the header file is included.In summary, the declarations can be shared through a header file, while the mapping of declarations to definitions is done by the linker.