471,831 Members | 1,186 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,831 software developers and data experts.

vector<pair..> >::iterator

Hi
is it ok to do this? if not, then how

for (vector<pair<char,double::const_iterator it = v.begin(); it != v.end(); ++it)
switch (*it->first){...

thanks
Jul 31 '06 #1
3 7304
Gary Wessle wrote:
is it ok to do this? if not, then how

for (vector<pair<char,double::const_iterator it = v.begin(); it
!= v.end(); ++it) switch (*it->first){...
'it->first' is a char. You cannot dereference a char. You have one
too many indirections. Either use

switch (it->first) {

or

switch ((*it).first) {

Which should be the same AFA C++ is concerned.

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Aug 1 '06 #2
Gary Wessle wrote:
is it ok to do this? if not, then how

for (vector<pair<char,double::const_iterator it = v.begin(); it != v.end(); ++it)
switch (*it->first){...
No. Did you even try it? The element "first" is not a pointer, so you
can't dereference it. Drop the star *or* parenthesize (*it) and change
the arrow to a dot, and then it will compile.

Cheers! --M

Aug 1 '06 #3
Gary Wessle <ph****@yahoo.comwrites:
Hi
is it ok to do this? if not, then how

for (vector<pair<char,double::const_iterator it = v.begin(); it != v.end(); ++it)
switch (*it->first){...
never mind, I found it after some trial and error

switch( (*it).first )
Aug 1 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

7 posts views Thread by ma740988 | last post: by
9 posts views Thread by aaragon | last post: by
4 posts views Thread by Bobrick | last post: by
1 post views Thread by atomik.fungus | last post: by
2 posts views Thread by subramanian100in | last post: by
9 posts views Thread by t | last post: by
6 posts views Thread by muzicmakr | last post: by
NeoPa
reply views Thread by NeoPa | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.