Solved

Please explain std::pair, std::map and std::set statements

Posted on 2006-11-16
1
531 Views
Last Modified: 2008-02-01
Would someone please explain these item by item. Thanks. 100 points each! (I'll increase points as required)


typedef std::pair<CString, NameType> NameEntry;
   std::map<NameEntry, CString> m_oNameMap;
   std::set<CString> m_oUsedNameSet;
0
Comment
Question by:Christopher Schene
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 86

Accepted Solution

by:
jkr earned 100 total points
ID: 17957594
pair<T1,T2> is a heterogeneous pair: it holds one object of type T1 and one of type T2. (http://www.sgi.com/tech/stl/pair.html)

map<Key, Datais a Sorted Associative Container that associates objects of type Key with objects of type Data. Map is a Pair Associative Container, meaning that its value type is pair<const Key, Data>. (http://www.sgi.com/tech/stl/Map.html)

set<Key, Compare> is a Sorted Associative Container that stores objects of type Key. Set is a Simple Associative Container, meaning that its value type, as well as its key type, is Key (http://www.sgi.com/tech/stl/set.html)

In your code, 'NameEntry' is defined to be a 'std::pair<CString, NameType>', then a map is created that maps such a 'NameEntry' to a string (a MFC CString to be more precise). Finally, there is a set of CStrings, which means a (sorted) collection of CStrings where each entry is unique.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
c++ how to tell if the progra is ctl or mfc atl ect 6 99
C++ Language error 28 280
Compile GLUT with Visual Studio 2015 1 206
basic hardware to learn oop advanced design patterns 3 110
Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question