2011-04-25 105 views
0

我搜索了一个范例程序与CList.But上下工夫我找不到它。我得到了有关CLISTS一些基本定义(即行为类似于双向链表模板类)..和用于存储data..The第一个参数是由list..I看不见存储哪些元素在列表中,以及如何检索它内部存储的总和。在C++中使用CLISTS -Could不明白

RsData Data; //object of class RsData 
RsEvent* Event;//pointer to class RsEvent 
CList<Event*,Event*> EventQueue; 
Data.EventQueue.RemoveAll(); 
//removing the attributes and methods of the class RsEvent stored in the list. 
+0

哪里此栏列表类从何而来?也许你可以提供一个编译的例子? – 2011-04-25 03:57:36

+0

在afxtempl.h ...模板<类类型,类ARG_TYPE = const型&>类分栏列表:公共CObject的{保护:结构CNode {CNode * pNext; CNode * pPrev; TYPE数据; };撑条; }; – Angus 2011-04-25 04:07:11

+1

你为什么不考虑'std :: list'?它在Stroustroup的书“The C++ Programming Language”中有所描述,在STL的书籍中,它是标准的。 – Begemoth 2011-04-25 04:46:22

回答

1

所以DOC是CList on MSDN

而且没有为COLLECT Sample: Illustrates MFC Collection Classes

我不知道这是如何文档没有被发现的链接出现,所以也许需要被clarrified你的问题。

列表提供前/后插入和期待,藏汉作为迭代方法。

// Define myList. 
CList<CString,CString&> myList; 

// Add an element to the front of the list. 
myList.AddHead(CString("ABC")); 

// Verify the element was added to the front of the list. 
ASSERT(CString("ABC") == myList.GetHead()); 
+0

嗨,我做了你在这里给出的....#包括“stdafx.h”#include“afxtempl.h”#include #define _AFXDLL using namespace std; int main(){CList myList; myList.AddHead((CString的( “ABC”))); ASSERT((CString的( “ABC”)== myList.GetHead()));返回0; }输出:得到编译器错误,建设MFC应用程序与/ MD [d](CRT DLL版本)需要MFC共享的DLL版本。请#define _AFXDLL或不要使用/ MD [d] ... – Angus 2011-04-25 05:58:47

+0

您缺乏知识目前无法帮助 – 2011-04-25 08:14:41

+0

@Beata - 该消息告诉您什么是错的!你必须选择相同版本的MFC和CRT,既可以作为DLL也可以作为静态库。 – 2011-04-25 08:26:22