单文挡多视图显示的一个小问题 GetDocument;

aguo2006 2006-08-07 10:47:12
我在制作单文挡多试图显示的一个程序是:

按一本书上的说明先增加了一个视图类CBarView
class CBarView : public CView
{
..............
};
然后按照书上的说明要为CBarView类添加文挡视图的交互函数GetDocument(),得到
class CBarView : public CView
{
..............
Public:
CPROG3Doc * GetDocument(); // CPROG3Doc文挡类
};

CPROG3Doc* CBarView::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CPROG3Doc)));
return (CPROG3Doc*)m_pDocument;
}

我在的函数中用
void CBarView::OnDraw(CDC* pDC)
{
CPROG3Doc* pDoc = GetDocument();
.........................................
}

总是出一大堆错误呢?

syntax error : missing ';' before '*'
'CPROG3Doc' : missing storage-class or type specifiers
'GetDocument' : missing storage-class or type specifiers

'initializing' : cannot convert from 'int *' to 'class CPROG3Doc *'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast


但是 光盘里的例子程序是一样的 却能够正常运行...

各位大侠 帮我看看 先多谢了!!
...全文
258 5 打赏 收藏 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
handsomerun 2006-08-07
  • 打赏
  • 举报
回复
class CBarView : public CView
在这行上面声明一下CPROG3Doc 类就可以了

Class CPROG3Doc ;
molan_1206 2006-08-07
  • 打赏
  • 举报
回复
加入#include "PROG3Doc.h"
aiguo26 2006-08-07
  • 打赏
  • 举报
回复
syntax error : missing ';' before '*'
'CPROG3Doc' : missing storage-class or type specifiers
'GetDocument' : missing storage-class or type specifiers

说明'CPROG3Doc' 没有定义
所以,要加上头文件PROG3Doc.h
折腾_苏州 2006-08-07
  • 打赏
  • 举报
回复
DentistryDoctor is right!
BarView.h文件里class CBarView : public CView
前加上#include "PROG3Doc.h"
DentistryDoctor 2006-08-07
  • 打赏
  • 举报
回复
引入文档类的定义

#include "PROG3Doc.h"

16,550

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC相关问题讨论
社区管理员
  • 基础类社区
  • Creator Browser
  • encoderlee
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

        VC/MFC社区版块或许是CSDN最“古老”的版块了,记忆之中,与CSDN的年龄几乎差不多。随着时间的推移,MFC技术渐渐的偏离了开发主流,若干年之后的今天,当我们面对着微软的这个经典之笔,内心充满着敬意,那些曾经的记忆,可以说代表着二十年前曾经的辉煌……
        向经典致敬,或许是老一代程序员内心里面难以释怀的感受。互联网大行其道的今天,我们期待着MFC技术能够恢复其曾经的辉煌,或许这个期待会永远成为一种“梦想”,或许一切皆有可能……
        我们希望这个版块可以很好的适配Web时代,期待更好的互联网技术能够使得MFC技术框架得以重现活力,……

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