如题。我新建一个类,并将该类的基类设置为CTreeView,新建后编译,不知怎么回事,却发现有9个错误。错误信息如下:--------------------Configuration: TvwDemo - Win32 Debug--------------------
Compiling...
TvwList.cpp
d:\tvwdemo\tvwlist.h(14) : error C2504: 'CTreeView' : base class undefined
D:\TvwDemo\TvwList.cpp(16) : error C2440: 'return' : cannot convert from 'class CTvwList *' to 'class CObject *'
        Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
D:\TvwDemo\TvwList.cpp(16) : error C2653: 'CTreeView' : is not a class or namespace name
D:\TvwDemo\TvwList.cpp(16) : error C2065: 'classCTreeView' : undeclared identifier
D:\TvwDemo\TvwList.cpp(27) : error C2653: 'CTreeView' : is not a class or namespace name
D:\TvwDemo\TvwList.cpp(38) : error C2065: 'GetDocument' : undeclared identifier
D:\TvwDemo\TvwList.cpp(38) : 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
D:\TvwDemo\TvwList.cpp(48) : error C2653: 'CTreeView' : is not a class or namespace name
D:\TvwDemo\TvwList.cpp(53) : error C2653: 'CTreeView' : is not a class or namespace name
Error executing cl.exe.TvwDemo.exe - 9 error(s), 0 warning(s)还望高手指点.谢谢!

解决方案 »

  1.   

    在TvwList.cpp加入#include "TreeView.h"
      

  2.   

    还是不行。提示两个错误:d:\tvwdemo\tvwlist.h(14) : error C2504: 'CTreeView' : base class undefined
    D:\TvwDemo\TvwList.cpp(7) : fatal error C1083: Cannot open include file: 'TreeView.h': No such file or directory
    Error executing cl.exe.
      

  3.   

    'CTreeView' 类的声明,不是在"TreeView.h"里面的,当然编译错误啦
    从MSDN里面找一下'CTreeView' 对应的头文件,包含它就是了
      

  4.   

    应该不是这样的,因为我下载别人的源码,也是建立了以CTreeView为基类的新类,别人的代码里面根本就没有提到CTreeView对应的头文件,而且编译也能通过。不知为何。
      

  5.   

    找到了CTreeView类对应的头文件,将头文件#include "afxcview.h"加入,同样出错误信息。
      

  6.   

    自己解决了。是在头文件中加入下面代码就可以了。
    #ifndef __AFXCVIEW_H__
    #include <afxcview.h>
    #endif谢谢诸位!