在CMainFrame中直接添加 #include "TestSDIView.h" ,出现如下错误:
1>e:\vc程序\vc_testprogram\testsdi\testsdi\testsdi\testsdiview.h(16): error C2143: 语法错误 : 缺少“;”(在“*”的前面)
1>e:\vc程序\vc_testprogram\testsdi\testsdi\testsdi\testsdiview.h(16): error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int
1>e:\vc程序\vc_testprogram\testsdi\testsdi\testsdi\testsdiview.h(16): error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int
1>e:\vc程序\vc_testprogram\testsdi\testsdi\testsdi\testsdiview.h(16): warning C4183: “GetDocument”: 缺少返回类型;假定为返回“int”的成员函数
解决方案很简单,多加一个头文件,即 #include "TestSDIDoc.h" #include "TestSDIView.h"
至于网上的另一种解决方案,即CMainFrame头文件中添加声明的方式貌似不靠谱,错误依旧。好像很多人都是这样回答的,可有没有人试过不好说,希望不懂没试过的人不要乱说,对一个程序员而言,以为某种方案是正确的,自己却始终无法解决问题,是件非常纠结难受的事情,大家都懂的~
本文解决了在CMainFrame中直接添加TestSDIView.h导致的编译错误问题,通过添加额外的TestSDIDoc.h头文件成功解决了错误C2143、C4430及警告C4183等问题。
2759

被折叠的 条评论
为什么被折叠?



