在MFC中,想在CMyDialog里面调用CMyView里面的函数,出问题了

yingzijuntuan 2012-10-25 11:48:44
通过查资料,我知道可以

CMainFrame * pMain=(CMainFrame *)AfxGetApp()->m_pMainWnd;
CMyView * pView=(CMyView *)pView->GetActiveView();

但是,在定义CMyView需要包含头文件,于是我在CMyDialog的源文件里面加了#include "图论View.h"(工程名叫图论)
但是加了后出现了问题

d:\program files (x86)\microsoft visual studio\myprojects\图论\图论view.h(21) : error C2143: syntax error : missing ';' before '*'
d:\program files (x86)\microsoft visual studio\myprojects\图论\图论view.h(21) : error C2501: 'CMyDoc' : missing storage-class or type specifiers
d:\program files (x86)\microsoft visual studio\myprojects\图论\图论view.h(21) : error C2501: 'GetDocument' : missing storage-class or type specifiers

于是我展开说少了分号的那句,指示错误为
CMyDoc * GetDocument();
求帮忙!
...全文
177 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
yingzijuntuan 2012-10-27
  • 打赏
  • 举报
回复
我知道有这些情况,我现在想知道我那是什么情况呀?怎么会出现那种错误?
schlafenhamster 2012-10-25
  • 打赏
  • 举报
回复
"展开说少了分号的那句" 其实是有类型未定义
Eleven 2012-10-25
  • 打赏
  • 举报
回复
View类的.h上面加上class CXXXXDoc;
华美乐章 2012-10-25
  • 打赏
  • 举报
回复
加上2个头文件 #include “XXXDoc.h”
#include "XXXView.h"
great_kevin 2012-10-25
  • 打赏
  • 举报
回复
很多时候,错误提示不准确,如3F所说,可能是类型未定义,或者其他错误,他就提示啥少分号,mark,学习一下
yingzijuntuan 2012-10-25
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 的回复:]
View类的.h上面加上class CXXXXDoc;
[/Quote]
这样改动确实ok了,但是具体是怎么回事呀?这个问题是怎么出来的?

15,979

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 界面
社区管理员
  • 界面
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧