我创建一个SDI,命名为test,在最后一步改为CFormView,,,添加一个对话框,并生成类c1,
在c1.cpp,包含testview.h,如下:
#include "stdafx.h"
#include "test.h"
#include "c1.h"
#include "testview.h"
出错如下:
Compiling...
c1.cpp
d:\test\testview.h(27) : error C2143: syntax error : missing ';' before '*'
d:\test\testview.h(27) : error C2501: 'CTestDoc' : missing storage-class or type specifiers
d:\test\testview.h(27) : error C2501: 'GetDocument' : missing storage-class or type specifiers
Error executing cl.exe.
为什么不能包含呀?但是在testview.cpp中包含test.h却可以,这是大家都知道的我想在对话框中调用视类(CTestView)的成员变量(自己定义的),最好怎么作,假设这个变量是int n,代码怎么写

解决方案 »

  1.   

    在CTestView类的头文件里包含TestDoc.h头文件
      

  2.   

    这个方法可以解决编译错误,但是,我怎么访问CTestView的成员变量呀,给点代码,我不知怎么获取指针呀
      

  3.   

    要访问CTestView的成员,要能取得一个它的实例呀. 这个要具体问题具体分析了. 
      

  4.   

    在你的对话框头文件中再包含#include "MainFrm.h"然后((CTestView*)((CMainFrame *)AfxGetMainWnd())->GetActiveView())->n