Hey Daniweb! I'm here again with another C++ problem.

I am trying to add three pairs into my main vector 'theMap'. I am thinking I need to use the 'insert' function, but I just cant figure out why my syntax is working.

I've tried the 'copy' command as well, no dice.
Here is are my definitions. theMap should pickup one,two, and three.

map<int,string> theMap;
pair<int,string> one,two,three;

** one, two, and three only have three functions. (first,second, and swap).
* pair is a struct.

Recommended Answers

All 3 Replies

Since we're not yet in the age of Big Brother and we can't look over each others shoulders yet, please post relevant code.

Since we're not yet in the age of Big Brother and we can't look over each others shoulders yet, please post relevant code.

What code do you need?
I've got about 10 header files and 12 cpp files - I am just using the standard vector type.

I need to know which of the follow commands I can use here.
http://www.cppreference.com/wiki/stl/vector/start
I went there - but their examples didn't help much.

class std::map<typename_Kty, typename _Ty, typename_Pr, typename_alloc>
struct std::pair<typename_Ty1, typename_Ty2>

I need to add three pairs (one,two,three) into 'theMap' using the member functions of map (which are just standard vector members).

map<int,string> theMap;
pair<int,string> one,two,three;
/***** BEGIN STUDENT CODE *****/
// Add three pairs into `theMap'. According to the documentation, which of the
// map members (i.e. member functions) will do the job?
theMap.begin();
theMap.insert(make_pair (1, "One") );
theMap.insert (make_pair (2, "Two") );
theMap.insert(make_pair (3, "Three") );

Figured it out.

MAPS =/ Vectors.

/bonk

Sorry for any confusion.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.