A #include is equivalent to literally copying and pasting the entire header file into wherever it is included into.
So if you have foo.cpp which includes foo.h and bar.h, and bar.h also includes foo.h, then the resulting source file is compiled with the contents of foo.h pasted into it twice.
The include guards just tell the compiler to ignore any subsequent copies of that header within the resulting source file being compiled. It still copies it in there twice, but the second occurrence is ignored. Some compilers allow you to use "#pragma once" at the top of the file which actually stops the second and subsequent inclusions of the header, but it's not supported on all compilers.
thanks for the explanation:)
Originally Posted by iMalc