Sun Studio 12: C++ User's Guide

5.1.2 Idempotent Header Files

Your header files should be idempotent. That is, the effect of including a header file many times should be exactly the same as including the header file only once. This property is especially important for templates. You can best accomplish idempotency by setting preprocessor conditions that prevent the body of your header file from appearing more than once.


#ifndef HEADER_H
#define HEADER_H
/* contents of header file */
#endif