| re: stl map question
Buster Copley <buster@none.com> writes:
[color=blue]
> Thomas wrote:[color=green]
> > I have a question about how the stl map class works. I have a subscription
> > class that I use to manage client application subscriptions. These are
> > stored in a map. Periodically, I need to update the subscriptions
> > in the map
> > to reflect changes to data. When I iterate over the map, I expect to get a
> > reference to the object stored in the map using
> > myclass mc = *iter->second;[/color]
> [snip]
>
> C++ is not Java. This declares an object of class mc and copy-
> initializes it from the reference returned by "* (iter->second)".
>
> If you want "mc" to be a reference to a myclass object, declare
> it as such:
>
> myclass & mc = * (iter->second);[/color]
Alternatively, since you seem to store pointers to myclass in the map, just
use pointers:
myclass* mc = iter->second;
regards
frank
--
Frank Schmitt
4SC AG phone: +49 89 700763-0
e-mail: frankNO DOT SPAMschmitt AT 4sc DOT com |