468,497 Members | 1,869 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,497 developers. It's quick & easy.

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 7071
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
reply views Thread by NPC403 | last post: by
3 posts views Thread by gieforce | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.