头文件交叉定义出现--GetDocument missing storage-class or type specifiers错误的解决方法
来源:互联网 发布:微信闪退修复软件 编辑:程序博客网 时间:2024/06/05 06:22
GetDocument missing storage-class or type specifiers的解决方法
error C2143: syntax error : missing ';' before '*'
error C2501: 'CTest1Doc' : missing storage-class or type specifiers
error C2501: 'GetDocument' : missing storage-class or type specifiers
遇到这种莫名的错误,最可气了。
当我在childFrm中加入 #include "CMyView.h"便报的错
解决方法1是:
是在自己要使用的View类的.cpp文件中加入下面一句声明:
class CMyDoc;
解决方法2是:
是在自己要使用的View类的.cpp文件
#include "XXXDoc.h"
#include "XXXView.h"
#include "MainFrm.h"
具体的,可以拿三峡(周达超编的)应用程序来说明~~
CPlatformGL这个类中,要用到CModuleGL这个类,
CModuleGL这个类,也要用到CPlatformGL这个类, 如果正常的在头文件交叉包含的话,很容易出现上面描述的编译问题,
解决方法1:
在CPlatformGL这个类的头文件中,加上#include "ModuleGL.h"
另外,还有在整个类的定义前,加上class CModuleGL; //类声明,避免交叉定义
(我看到周达超程序还在类定义前,加上了using namespace std;//命名空间,不知道和这个有没有关系)
同样的,
在CModuleGL这个类的头文件中,加上#include "PlatFormGL.h",
在类的定义前,加上class CModuleGL;
三峡程序的第二个例子~~
在SXSystem这个类中,需要获取视图类CSXS_testView类的指针(即,要用到视图类),
在视图类中也要调用SXSystem类,如实就有下面的解决方法~~
解决方法2:
在SXSystem类的源文件(*.cpp文件,而不是*.h)中,包含了三个文件,如下:
#include "MainFrm.h"
#include "SXS_testDoc.h"
#include "SXS_testView.h"
而在视图类中,只需在头文件包含SXSystem类即可,即#include "SXSystem.h"
以上是两种常规的解决方法,都很好用~~(用第一种较多)
- 头文件交叉定义出现--GetDocument missing storage-class or type specifiers错误的解决方法
- GetDocument missing storage-class or type specifiers的解决方法
- error C2501: 'GetDocument' : missing storage-class or type specifiers 问题的处理
- missing storage-class or type specifiers的解决方法
- '_ConnectionPtr' : missing storage-class or type specifiers
- 'HDEVNOTIFY' : missing storage-class or type specifiers
- 'IplImage' : missing storage-class or type specifiers
- 'HDEVNOTIFY' : missing storage-class or type specifiers
- 'IplImage' : missing storage-class or type specifiers
- '_ConnectionPtr' : missing storage-class or type specifiers
- [VC++]missing storage-class or type specifiers
- missing storage-class or type specifiers的原因及解决办法
- 有关error C2501: 'WINGDIAPI' : missing storage-class or type specifiers的错误
- unexpected 'class***或error C2501: missing storage-class or type specifiers 错误解决办法
- error C2501: 'string' : missing storage-class or type specifiers
- error C2501: 'gxListCtrl' : missing storage-class or type specifiers
- error C2501: '_Application' : missing storage-class or type specifiers
- error C2501: 'AUX_RGBImageRec' : missing storage-class or type specifiers
- AdventureWorks2008 数据文件下载(含mdf和ldf文件)
- 2014/3/27 Spring AOP编程心得
- javaScript
- ssh-copy-id命令详解
- 【vijos】P【1836】 坑人的01背包
- 头文件交叉定义出现--GetDocument missing storage-class or type specifiers错误的解决方法
- ThinkAndroid框架 网络状态监听原理
- 学习Canvas 画圆锥,并且作为一个统计图
- rm命令
- bom_dom
- Android 4.0 不能访问网络问题
- Initialization of bean failed; nested exception is java.lang.NoClassDefFoundError: org/aspectj/weave
- Http响应码
- Linux挂载U盘:mount: unknown filesystem type 'ntfs'