Analysis of the causes of errors in G + + compilation “was not declared in this scope”“

When compiling the program, prompt: “Was not declared in this scope”.

This is the simplest case ~ but I often make the mistake (basic is also the reason of this a few of the most likely)

in addition, the Internet was also pointed out the following reasons can cause the prompt error:
2. A dependency error occurred when header files #include each other. For example, the header file forms a circular dependency,

/***file a ****/
#ifndef FILE_A_
#define FILE_A_
#include <file b>
#endif 


/****file b ***/
#ifndef FILE_B_
#define FILE_B_
#include <file a>
#endif 

If variables, functions, and classes in file A are used in file B, then #ifndef and #define are used in file B, and #include <; file a> Unable to execute #include 3. Header file name when accidentally and header files in the library name repetition, and in the program using the library of the header file.
so, will cause the macro name repetition, there must be a header file for # # ifndef lost effect. Was not decleared in this scope?The header file was not decleared in this scope

Read More: