vc的容器选择

xiaodong60606 2016-03-07 11:47:12
vc本身有自己的容器cmap clist 等等,stl也有容器,现在vc新版本已经把stl整合进去了,编程的时候用标准的容器好还是用stl的容器好?该怎么选择?谢谢。
...全文
146 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
  • 打赏
  • 举报
回复
容器都差不多。你喜欢哪个就用那个。大同小异。我以前爱用vector。后面发现那个释放麻烦。CArray似乎也不错。后面我发现干脆用结构体数组也能搞定。何必呢。那个看着顺眼。那个觉得习惯就用那个。。
赵4老师 2016-03-08
  • 打赏
  • 举报
回复
COLLECT: Illustrates MFC Collection Classes Click to open or copy the COLLECT project files. COLLECT illustrates a wide variety of collection classes offered by the Microsoft Foundation Class Library (MFC). The MFC collection classes can be classified according to shape and design. MFC offers classes for three types of collection shapes: Lists Arrays Maps and three types of designs: No use of C++ templates. Use of a C++ template–based collection of simple elements. Use of a C++ template–based collection of type-safe pointers. The following table identifies all the MFC collection classes sorted according to shape and design. The COLLECT sample illustrates nine of these collections, one from each cell in the table. Each represents a distinct combination of shape and design. Also, because usage of the CTypedPtrArray and CTypedPtrList template-based collections differs according to whether they are used to hold pointers to CObjects or to non-CObjects, the COLLECT sample illustrates both cases. The nine collections illustrated by COLLECT are indicated with an asterisk. Collection shapes Non-template based Template-based simple elements Template-based typeSafe pointers List CStringList* CList* CTypedPtrList CObList (of pointers)* CPtrList CTypedPtrList (of CObjects) Array CByteArray CArray* CTypedPtrArray CUIntArray (of pointers) CWordArray* CDWordArray CTypedPtrArray CStringArray (of CObjects)* CPtrArray CObArray Map CMapWordToPtr CMap* CTypedPtrMap* CMapWordToOb CMapStringToString* CMapStringToPtr CMapStringToOb CMapPtrToWord CMapPtrToPtr Additional COLLECT Features In addition to illustrating the MFC collection classes, COLLECT also illustrates: Coordinating the addition and removal of entries in a list box with the addition and removal of entries in a collection. Switching between different views of a document, with only one shown at a time. That is, although COLLECT has many different views, it has a single-document interface (SDI) instead of a multiple-document interface (MDI). The Example menu lists nine collection class illustrations organized according to the above table. Each example presents a form view that exercises many of the common collection operations: Adding a new element. Inserting a new element in the middle of a list. Searching an element (by clicking its entry in the dialog box's list box). Searching an entry in the map by entering the Key and clicking Find. Updating the value of an element. Removing an element. Removing all the elements of the collection. You can save changes to all the examples with File Save and read them back with File Open. This sample demonstrates the following keywords: AfxMessageBox; CCmdUI::SetCheck; CControlBar::EnableDocking; CDialog::DoModal; CDocument::DeleteContents; CDocument::OnNewDocument; CFrameWnd::DockControlBar; CFrameWnd::EnableDocking; CFrameWnd::GetActiveDocument; CFrameWnd::GetActiveView; CFrameWnd::RecalcLayout; CFrameWnd::SetActiveView; CListBox::AddString; CListBox::DeleteString; CListBox::FindString; CListBox::GetCurSel; CListBox::GetItemData; CListBox::GetItemDataPtr; CListBox::GetText; CListBox::InsertString; CListBox::ResetContent; CListBox::SetItemData; CListBox::SetItemDataPtr; CObject::AssertValid; CObject::Dump; CObject::Serialize; CStatusBar::Create; CStatusBar::SetIndicators; CString::Empty; CString::Format; CString::LoadString; CToolBar::Create; CToolBar::LoadBitmap; CToolBar::SetButtons; CView::DoPreparePrinting; CView::GetDocument; CView::OnBeginPrinting; CView::OnDraw; CView::OnEndPrinting; CView::OnInitialUpdate; CView::OnPreparePrinting; CView::OnUpdate; CWinApp::AddDocTemplate; CWinApp::Enable3dControls; CWinApp::InitInstance; CWinApp::LoadStdProfileSettings; CWinApp::OnFileNew; CWnd::DestroyWindow; CWnd::DoDataExchange; CWnd::OnCreate; CWnd::ShowWindow; CWnd::UpdateData; LoadString; SetWindowLong
  • 打赏
  • 举报
回复
VC很旧的版本就有STL啊。 尽量能够使用STL就用STL的。除非是和mfc交互的地方需要CMap之类的做参数。
sinat_26014465 2016-03-07
  • 打赏
  • 举报
回复
都行的。你觉得哪个感觉好就用那个。不就是为了保存数据吗?何必究竟。要是喜欢操练。干脆自己写链表和数组算了。高手都是自己操练的比较多。
微型蚂蚁 2016-03-07
  • 打赏
  • 举报
回复
wo一般用stl

16,473

社区成员

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

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

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