Whybother wrote:
I have class CMyClass to which I create objects of and store a count of them
in a stl map. (stlport)
like so
typedef map<CMyClass, unsigned, myclass_less> Results_Map;
...
Results_Map m_Map;
...
...
CMyClass mc(...);
m_Map[mc]++;
...
How can I get access to the same mc object I just added to the map? In other
words I'm trying to do something like
CMyClass& mcRef = *m_Map[mc];
If thats possible.
I think you're confused with how 'map' works. You store _unsigned_ values
there. You make your objects the _keys_ for those unsigned values. Keys
get _copied_. If you need to find what key a particular unsigned value
has, you can _search_ for that value and then look at the key through the
iterator you get back...
Indexing by an object will get you the 'unsigned' part of the map. For
example
m_Map[mc]
results in a reference to the unsigned value corresponding to the counter
of the objects that have the same "value" as 'mc'. But if you have 'mc',
why do you need a reference to it?
IOW, based on what you wrote here and the questions you asked, I have no
clues as to what you're trying to do. What is it you're attempting to
accomplish? Perhaps 'map' is not the best solution, or perhaps you need
to define it differently...
V
--
Please remove capital As from my address when replying by mail