一个SDI程序,
我在VIEW类的CPP文件中要用到MainFrm的指针 所以 #include "MainFrm.h"
然后又一对话框类MyDlg(非模式对话框),在MainFrm中作为成员对象,所以MainFrm.h文件里 又#include "MyDlg.h"
最后是一个自绘控件,这个控件是在对话框中作为成员变量的,也就是说MyDlg.h中 #include "MyCtrl.h"
而控件类中需要引用View类指针,因此在其MyCtrl.CPP文件中还得#include "MyView.h"最后编译出错
e:\tcs\myview.h(22) : error C2143: syntax error : missing ';' before '*'
e:\tcs\myview.h(22) : error C2501: 'CMyDoc' : missing storage-class or type specifiers
e:\tcs\myview.h(22) : error C2501: 'GetDocument' : missing storage-class or type specifiersclass CMyView : public CView
{
protected: // create from serialization only
CMyView();
DECLARE_DYNCREATE(CMyView)// Attributes
public:-> CMyDoc* GetDocument(); 指向是这行 出错怎么弄啊
我在VIEW类的CPP文件中要用到MainFrm的指针 所以 #include "MainFrm.h"
然后又一对话框类MyDlg(非模式对话框),在MainFrm中作为成员对象,所以MainFrm.h文件里 又#include "MyDlg.h"
最后是一个自绘控件,这个控件是在对话框中作为成员变量的,也就是说MyDlg.h中 #include "MyCtrl.h"
而控件类中需要引用View类指针,因此在其MyCtrl.CPP文件中还得#include "MyView.h"最后编译出错
e:\tcs\myview.h(22) : error C2143: syntax error : missing ';' before '*'
e:\tcs\myview.h(22) : error C2501: 'CMyDoc' : missing storage-class or type specifiers
e:\tcs\myview.h(22) : error C2501: 'GetDocument' : missing storage-class or type specifiersclass CMyView : public CView
{
protected: // create from serialization only
CMyView();
DECLARE_DYNCREATE(CMyView)// Attributes
public:-> CMyDoc* GetDocument(); 指向是这行 出错怎么弄啊
(view类声明中用的是Doc *,因此一般包含在cpp文件中就可以了)
或者使用
#ifndef xxxxxx__H
#define xxxxxx__H
...头文件内容
#endif
#include "MyDoc.h"
#include "MyView.h"
这个顺序不能颠倒!!!!!!!!!