Hi,

I am trying to develop one requirement wherein I need a C++ map having both Key and Value as Structures.

The structures are as follows:

typedef struct _keyInfo
{
int Key1;
int Key2;
} T_KeyInfo, * T_pKeyInfo;

typedef struct _valueInfo
{
int value1;
int value2;
int value3;
} T_ValueInfo, * T_pValueInfo;

and my map is:

typedef map<T_pKeyInfo, T_pValueInfo> T_Map, * T_pMap;

I tried to insert one row into this map using the insert command:

M_pMap->insert(T_Map::value_type(L_pKey,L_pValue));

and Later I am trying to retrive the stored values in the map using find command

T_Map::iterator L_iterator;
T_pKeyInfo L_pKey = NULL;
T_pValueInfo L_pValue = NULL;

L_iterator = M_pMap->find(T_Map::key_type(L_pKey));
if (L_iterator != M_pMap->end())
{
L_pValue = L_iterator->second;
int P_Result=L_pValue->value1;
}

Somehow I am not able to retrive the value1 from the map using the above code.

Can anyone please help me in resolving this issue.
It will be OK, if any better approach/procedure exists to have a map with key and value as structs.

Thanks in advance...............


karthik