What is a guard block for a header file in C++?
问题 I'm trying to make a C++ class using the Code::Blocks IDE and there is a field called "Guard block." I've done a search and haven't been able to find any useful information. What is this field for? Thanks. 回答1: Guard blocks are used to protect against the inclusion of a header file multiple times by the same compilation unit (c++ file). They look something like this: // Foo.h #ifndef INCLUDE_FILE_NAME_HERE_H_ #define INCLUDE_FILE_NAME_HERE_H_ class Foo { }; #endif If you include the same file