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 =
M.begin();
(*itor).PrintInfo();

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.

      
LVL 1
timberbtAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

timberbtAuthor Commented:
btw
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)
0
chensuCommented:
(*itor).second.PrintInfo();
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
chensuCommented:
If you want to access the string, use (*itor).first.
0
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

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!!!!
0
chensuCommented:
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();
    pair(const T& x, const U& y);
    template<class V, class W>
        pair(const pair<V, W>& pr);
    };
0
timberbtAuthor Commented:
Wonderful!  That makes perfect sense now, thanks again!
0
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.
0
chensuCommented:
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.
0
timberbtAuthor Commented:
ah, okay just wanted to make sure.  Thanks again.  
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C++

From novice to tech pro — start learning today.