Re: std:map
Fred wrote:
Oups..... forget about this one...
I've just found out were my error was.
In the main.c, I start populating the m_metaData variable in the
following way:
CIAMMetaDataCategory toto1, toto2;
m_metaData.insert(TIntCategoryPair(1,toto1));
m_metaData.insert(TIntCategoryPair(2,toto2));
Then I try to add some data to the CatResources variable:
TIntCategoryIt category_it = m_metaData.find(1);
CIAMMetaDataCategory category = category_it->second;
----> Above is the faulty line!!!
Ah yes, you need a reference, right?
CIAMMetaDataCategory& category = category_it->second;
BTW, a simpler way to insert elements in a map is
m_metaData[1] = toto1;
m_metaData[2] = toto2;
You can also use operator [] to extract elements if you know they are there
CIAMMetaDataCategory& category = m_metaData[1];
If the element is absent, a default constructed object is inserted and a
reference to it returned. Unlike operator [] for std::vector, there is no
overloaded version for const objects.
--
David Wilkinson
Visual C++ MVP