There are some useful techniques you can use without headaches. Actually, inclusion guard technique gets rid of annoying header reference problems with just a couple of lines.
1. Inclusion Guards
Large-scaled Production C++ applications tend to use lots of header files. Header files also include other header files. Therefore, it is common that one header file is included multiple times in the same compilation. This multiple inclusion causes multiple definition errors.
For this reason, C++ header files always use a preprocessor coding technique to prevent the content of the header file from appearing more than once.
#ifndef HEADER1_H #define HEADER1_H // actual header content #endif
The preprocessor symbol should be unique.
2. Pragma Directive
If you are useing VS C++, you can use the “pragma” directive.
#pragma once // actual header content