从MFC中的类CList派生 [英] Derive from the class CList in MFC

查看:93
本文介绍了从MFC中的类CList派生的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们可以从CList派生吗?如果是,那怎么办?
我尝试了以下操作,但出现编译时错误.

Can we derive from the CList? If yes then how?
I tried following thing but I am getting the compile time error.

class IIS_CList : public CList<cobject,>
{
...
}


我无法从CList派生它.我们应该怎么做?


I am not able to derive it from CList. How should we do it?

[更新]
谢谢

我听了你说的话.

如果我想以通用方式做到这一点,那我们应该怎么做?
表示如果我不知道类型是否为int,CString或其他类型
[/Update]
[Update]
thank you,

i followed what you said.

if i want to do this in generic way then what should we do for that?
means if i dont know whether the type is int, CString or may other
[/Update]

推荐答案

是的,您(当然)可以从CList派生,但是类作为以下模板签名"(请参见 CList文档 [ ^ ]):
Yes, you may (of course) derive from CList, however the CList class as the following ''template signature'' (see CList documentation[^]):
template< class TYPE, class ARG_TYPE = const TYPE& > 
class CList : public CObject



因此,您应该相应地从中导出,例如



Hence you should derive from accordingly, for instance

class MyList : public CList <int, int >
{
  // ...
};



是允许的.



is allowed.

[更新]
如果要在类中使用CList的通用性,请使用:
[Update]
If you want the same generality of the CList, in your class, then use:
template  <class TYPE, class ARG_TYPE = const TYPE&> 
  class MyList : public CList < TYPE, ARG_TYPE  >
  {
    //..
  };


[/Update]


[/Update]


这篇关于从MFC中的类CList派生的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆