is not a class or namespace name解决方法
2008-07-03 09:44
344 查看
is not a class or namespace name解决方法
每建立一个新类,都要在classname.cpp文件中加入#include "stdafx.h"文件,而且加的位置要在第一行;
原因:编译器通过一个头文件stdafx.h来使用预编译头文件,所谓头文件预编译,就是把一个工程(Project)中使用的一些MFC 标准头文件(如Windows.H、Afxwin.H)预先编译,以后该工程编译时,不再编译这部分头文件,仅仅使用预编译的结果。这样可以加快编译速度,节省时间。
预编译头文件通过编译stdafx.cpp 生成,以工程名命名,由于预编译的头文件的后缀是“pch”,所以编译结果文件是projectname.pch。编译器通过一个头文件stdafx.h 来使用预编译头文件。stdafx.h 这个头文件名是可以在project 的编译设置里指定的。编译器认为,所有在指令#include "stdafx.h"前的代码都是预编译的,它跳过#includestdafx. h"指令,使用projectname.pch 编译这条指令之后的所有代码。
因此,所有的CPP 实现文件第一条语句都是:#include "stdafx.h"。
相关文章推荐
- is not a class or namespace name解决方法
- 出现类似'CListView' : is not a class or namespace name的原因及解决方法
- is not a class or namespace name解决方法
- 【VC】编译出错is not a class or namespace name的解决办法
- std' : is not a class or namespace name,解决
- The project: nameXXX which is referenced by the classpath, does not exist解决方法?
- error C2653: 'QMessageBox' : is not a class or namespace name
- Error:The type or namespace name 'Office' does not exist in the namespace 'Microsoft' 解决方法
- supervisorctl报错"error: <class 'socket.gaierror'>, [Errno -2] Name or service not known"的解决方法
- jspsmartupload Files' name is invalid or does not exist的解决方法
- 关于:error C2653: 'MSXML2' : is not a class or namespace name
- is not a class or namespace name
- 编译错误提示:GetWeb.cpp(99) : error C2653: 'CWebPage' : is not a class or namespace name
- 关于Files' name is invalid or does not exist的解决方法
- struts2关于"There is no Action mapped for namespace / and action name"的解决方法
- this class is not key value coding-compliant for the key XXX错误的解决方法
- 没有躲过的坑--头文件相互包含(Compiler error C2653: not a class or namespace name)
- maven项目,多个依赖,打成一个可执行jar包,可根据profiles进行打包,出现的Could not find or load main class的解决方法。
- weblogic部署war包action不能访问问题解决方法 [There is no Action mapped for namespace / and action name]
- C++ 编译出现: error C2871: 'std' : does not exist or is not a namespace 怎么解决