对于派生MFC的问题!

madmanahong 2002-02-02 02:47:54
难道当我们派生MFC的类库的时候一定要包含一些头文件马?

向导没有做好马?

那我不知道一些类的头文件有怎么办〉

拿各位大虾的使用方法又是什么!

谢谢指教!
...全文
77 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
madmanahong 2002-02-24
  • 打赏
  • 举报
回复
谢谢你~了~

问题已经fixed~

:)
TKnight 2002-02-02
  • 打赏
  • 举报
回复
啊。。。这等怪事。。。:) [不敢相信是MFC被破坏了,即使破坏了也是被不小心修改了]

要不。。。你在WinApp派生的那个类的头文件中加上
#include "CLeftClient.h" [你的类缺省头文件]

再尝试一下。。。好吗?也许。。。是一个操作错误或者一个小Bug,
我在用ClassWizard引入一个DLL的时候也发生过类似错误。。。。

但是手动加上对头文件的引用之后修复了。。。

Lucky..........
madmanahong 2002-02-02
  • 打赏
  • 举报
回复
谢谢你呀~
可是我还是有些不明白!
为什么当我想在工程中加入一个新的类的时候,IDE变异却说没有定义!

譬如:用向导生成的时候一般是doc,view,app,frame这四者!
但是我想添加一个view!我也这么做了!
我是派生了一个CListView作为我的添加!
如:

class CLeftClient : public CListView
{
protected:
CLeftClient(); // protected constructor used by dynamic creation
DECLARE_DYNCREATE(CLeftClient)

// Attributes
public:

// Operations
public:

// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CLeftClient)
protected:
virtual void OnDraw(CDC* pDC); // overridden to draw this view
//}}AFX_VIRTUAL

// Implementation
protected:
virtual ~CLeftClient();
#ifdef _DEBUG
virtual void AssertValid() const;
virtual void Dump(CDumpContext& dc) const;
#endif

// Generated message map functions
protected:
//{{AFX_MSG(CLeftClient)
// NOTE - the ClassWizard will add and remove member functions here.
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};

/////////////////////////////////////////////////////////////////////////////

//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.

#endif // !defined(AFX_LEFTCLIENT_H__F9FE6960_17F3_11D6_98C6_444553540000__INCLUDED_)







但是当我编译的时候:他却说!
--------------------Configuration: Pro - Win32 Debug--------------------
Compiling...
LeftClient.cpp
e:\pro\leftclient.h(14) : error C2504: 'CListView' : base class undefined
E:\Pro\LeftClient.cpp(17) : error C2440: 'return' : cannot convert from 'class CLeftClient *' to 'class CObject *'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
E:\Pro\LeftClient.cpp(17) : error C2653: 'CListView' : is not a class or namespace name
E:\Pro\LeftClient.cpp(17) : error C2065: 'classCListView' : undeclared identifier
E:\Pro\LeftClient.cpp(28) : error C2653: 'CListView' : is not a class or namespace name
E:\Pro\LeftClient.cpp(39) : error C2065: 'GetDocument' : undeclared identifier
E:\Pro\LeftClient.cpp(39) : error C2440: 'initializing' : cannot convert from 'int' to 'class CDocument *'
Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
E:\Pro\LeftClient.cpp(49) : error C2653: 'CListView' : is not a class or namespace name
E:\Pro\LeftClient.cpp(54) : error C2653: 'CListView' : is not a class or namespace name
Error executing cl.exe.

Pro.exe - 9 error(s), 0 warning(s)


这到底是怎么回事?为什么IDE没有完成我所希望的代码?
又为什么error C2504: 'CListView' : base class undefined
没有定义!
他不是MFC中的内容马?
谢谢指点解答!!
TKnight 2002-02-02
  • 打赏
  • 举报
回复
你不必一定要包含头文件啊。。。你甚至可以整个
程序的源代码都放到一个文件中。

在VC++中,一般的情况头文件只是描述一个类的定义,而具体实现在同名的
CPP文件中。但是向导产生的程序框架有些时候也有例外。。。不过如果你顺
着类列表去访问,一点都感觉不出来。。。

Lucky...

16,551

社区成员

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

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

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