唉,唉,唉,还是这个老问题

xf166 2002-05-07 06:45:23
昨天在这里发如何理解,
====================
typedef CList<CRect, CRect> CListRect;
====================
得到了afsfop等老兄热心的帮助,之后我是这么理解的,
typedef A B
MSDN中这理解typedef :
The typedef keyword defines a synonym for the specified type-declaration.
看之后,我理解是把A种类型定义成意义更鲜明的新类型B

这里我的问题出来了,==》怎么理解 CList<CRect, CRect> ???

MSDN中这解释CList :
The CList class supports ordered lists of nonunique objects accessible sequentially or by value. CList lists behave like doubly-linked lists.

template< class TYPE, class ARG_TYPE >class CList : public CObject

是否这么理解呢:
以CRect成员类型的CList类型,重定义新类型CListRect
以后假如做了以下定义:

CRect rectWnd; //声明区域对象
GetWindowRect(&rectWnd);
//MSDN: address of structure window coordinates
listRect.AddTail(&rectWnd); //为listRect,添加入"新值"

不知道我理解得对不,希望得到热心人指点。
不理解透实在不爽,所以来问了,·_·.

========================================
http://as99.126.com/
========================================
...全文
31 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
diaopeng 2002-05-08
  • 打赏
  • 举报
回复
连typedef的作用都不知道?!悲哀,还是回去先找本C语言的书看看再问吧
xf166 2002-05-08
  • 打赏
  • 举报
回复
谢谢各位的指点,thanks
晨星 2002-05-07
  • 打赏
  • 举报
回复
CList的第一个参数是返回类型,第二个是参数类型。
比如
CList<A , B> List;
那么List.GetHead返回的就是A类型。
而成员AddTail的参数必须是B类型。
通常把A设置成类名,使得返回的是一个对象的拷贝。
而把B设置程类的引用,使得参数传递的效率高。
如:
CList<CString , CString&> StringList;
zniu 2002-05-07
  • 打赏
  • 举报
回复
just like std::list, CList is the same except some features.

CList is a template class, which means you should specify the actual type.

CRectList is just a alias of CList<CRect, CRect>

i hope this will be some help :)
seashoreboy 2002-05-07
  • 打赏
  • 举报
回复
typedef CList<CRect, CRect> CListRect
应该只是让你在需要写CList<CRect, CRect> 的地方只要写CListRect,方便。

69,369

社区成员

发帖
与我相关
我的任务
社区描述
C语言相关问题讨论
社区管理员
  • C语言
  • 花神庙码农
  • 架构师李肯
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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