Acessing functions in a map element

I'm attempting to access and element from the iterator returned by the STL map method Begin().

I did the following:itor =

and the PrintInfo is *DEFINATELY* a function that in the class which the map is created of.  The compiler returns:

error C2039: 'PrintInfo' : is not a member of 'pair<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const ,class genericcustomerclass>'

I have tried accessing it using the -> operator with no luck.  COuld someone *PLEASE* help me out.  I'm quite frustrated as everything I read seems to lead me to believe this should work just fine.  Thanks.

Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

chensuConnect With a Mentor Commented:
timberbtAuthor Commented:
itor was declared as follows:

customerlist::iterator itor;

and customerlist is:

typedef map<string,genericcustomerclass> customerlist;

and the void PrintAll() is a public function of the genericcustomerclass

(forgive the names, i was toying with a bunch of different ideas)
If you want to access the string, use (*itor).first.
The new generation of project management tools

With’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

timberbtAuthor Commented:
Wonderful!  COuld you explain what the .first and .second are doing?  And why the function is accessed via the .second?

None of my books seem to mention this, I'll accept the answer regardless, but I'd appreciate a better understanding.  Thanks!!!!
Take a look at the map template class. A map holds a set of ordered key/value pairs and the data type of each element is

typedef pair<const Key, T> value_type;

first and second are two member variables of the pair template struct.

template<class T, class U>
    struct pair {
    typedef T first_type;
    typedef U second_type
    T first;
    U second;
    pair(const T& x, const U& y);
    template<class V, class W>
        pair(const pair<V, W>& pr);
timberbtAuthor Commented:
Wonderful!  That makes perfect sense now, thanks again!
timberbtAuthor Commented:
did that give you 20 or 200 points?  I had this originally as a 200 point question but now it shows "20" at the top.  Don't want to rip you off or anything.
Thank you, I got 200 points x grade A. Once an answer is accepted, the points of a question become 10% for others to view.
timberbtAuthor Commented:
ah, okay just wanted to make sure.  Thanks again.  
All Courses

From novice to tech pro — start learning today.