C++: retrieve map values and insert into second map
- by donalmg
Hi,
I have one map within one header file class:
class One
{
// code
typedef map<string, int> MapStrToInt
inline MapStrToInt& GetDetails(unsigned long index)
{
return pData[index];
}
// populate pData....
private:
MapStrToInt *pData;
};
And a second class which implements another map and wants to get the first 10 details from the class One's map.
class Two
{
// code
One::MapStrToInt pDataTen;
int function1()
{
for (int i =0; i < 10; i ++)
{
One::MapStrToInt * pMap = &(One::GetDetails(i));
pDataTen.insert(pair<string, int>(pMap->first,pMap->second));
}
}
When I compile this, it states that pMap:
has no member named 'first'
has no member named 'second'
Any suggestions?
Thanks..