A number of inclusion of header information in C/C++ programming can result in compilation errors and undefined conduct. A header file usually accommodates operate declarations, macros, and different definitions which are included in a number of supply information. If a header file is included greater than as soon as in the identical compilation unit, the compiler could try and course of the identical declarations and definitions a number of occasions, leading to errors or surprising conduct.
To keep away from a number of inclusion of header information, the preprocessor directives #ifndef and #outline are generally used. These directives assist you to outline a preprocessor macro that’s solely outlined as soon as, even when the header file is included a number of occasions. The overall sample is as follows: