1 [problem background] Error C2065 appears in C++/MFC, that is, XXX is not defined, and the XXX you use is the base class library, do you think it may not exist?Except, of course, for your spelling mistakes, which I won’t discuss.
2 [Analysis] Check that the basic class library of VS/VC has no problem in loading and platform setting; This is usually due to placing certain header files in front of stdafx.h header files.
3 [Example of solution]
3.1 Question of the above title: Error C2065 ‘cout’: Undeclared Identifier. This is due to placing the header file “iostream.h” in the implementation file as follows:
// The following is the implementation of XXXX. CPP
# include & lt; iostream.h>
# include “stdafx. H”
/ /…
Int xxx_fun ()
{
STD: : cout< < somevar< < std::endl;
}
3.1.1 [Results] The above error C2065 will occur;
3.2 [Modification method] Put stdafx.h in the first place, and do not let the words of other header files come before it.
// The following is the implementation of XXXX. CPP
# include “stdafx. H”
# include & lt; iostream.h>
/ /…
Int xxx_fun ()
{
STD: : cout< < somevar< < std::endl;
}
3.2.1 [Results] There will be no Error C2065 above;
3.3 [Summary] If the library and platform are correctly configured, the above methods can be basically solved. This is a small mistake that is easy to overlook because we don’t usually feel the need to prioritize header files. Well, the devil is in the details, and the difference between first and second place in the arena is sometimes 0.001 seconds, so don’t make any small mistakes.
2 [Analysis] Check that the basic class library of VS/VC has no problem in loading and platform setting; This is usually due to placing certain header files in front of stdafx.h header files.
3 [Example of solution]
3.1 Question of the above title: Error C2065 ‘cout’: Undeclared Identifier. This is due to placing the header file “iostream.h” in the implementation file as follows:
// The following is the implementation of XXXX. CPP
# include & lt; iostream.h>
# include “stdafx. H”
/ /…
Int xxx_fun ()
{
STD: : cout< < somevar< < std::endl;
}
3.1.1 [Results] The above error C2065 will occur;
3.2 [Modification method] Put stdafx.h in the first place, and do not let the words of other header files come before it.
// The following is the implementation of XXXX. CPP
# include “stdafx. H”
# include & lt; iostream.h>
/ /…
Int xxx_fun ()
{
STD: : cout< < somevar< < std::endl;
}
3.2.1 [Results] There will be no Error C2065 above;
3.3 [Summary] If the library and platform are correctly configured, the above methods can be basically solved. This is a small mistake that is easy to overlook because we don’t usually feel the need to prioritize header files. Well, the devil is in the details, and the difference between first and second place in the arena is sometimes 0.001 seconds, so don’t make any small mistakes.
Read More:
- error C2065: ‘cout’ : undeclared identifier
- Error 3 error C2065: ‘endl‘ : undeclared identifier-Error 2 error C2065: ‘cout‘ : undeclared identif
- Error c2065: ‘new’: undeclared identifier, mainly because it is a. C file
- error C2065: ‘_beginthread‘ : undeclared identifier
- error C2065: “_ LPW “: undeclared identifier
- Format control of cout cout.width () and cout.fill ()
- To solve the error of T2a w2a a2w, error c2065:_ LPW “: undeclared identifier
- “Undeclared identifier” still reported in declaration header file
- Undeclared identifier CV in opencv4.2.0_ WINDOW_ AUTOSIZE
- IOS reverse error: use of undeclared identifier ‘mshookivar’
- Error in the latest version of ffmpeg: ‘codec’_ FLAG_ GLOBAL_ Header ‘undeclared identifier solution
- winnt.h C2146 error C2146: syntax error : missing ‘;’ before identifier ‘PVOID64’
- Error c3861: identifier not found | identifier not found
- Successfully resolved error c3861: ‘printf’: identifier not found
- “Error: ` cout ‘was not declared in this scope”
- error: `cout’ was not declared in this scope
- Error c3861: “strcasecmp”: identifier not found
- Error c2061: syntax error: identifier ‘this_ FILE’
- error C2146: syntax error : missing ‘;’ before identifier ‘fd’
- error: ‘cout’ is not a member of ‘std’