我有一张这样的地图:
typedef std::map<std::string, Copied_Instrument_Data> InternalIdWise_Copied_Instrument_Data;
其中,Copied_Instrument_Data
是一个结构:
typedef struct
{
std::string type;
std::string marketListId;
std::string sectorCode;
std::string validToDate;
int notificationType;
bool npgFlag;
}Copied_Instrument_Data;
我使用以下方法将数据插入到我的地图中:
InternalIdwise_Copied_Instrument_Data__Map.insert( std::pair<std::string, Copied_Instrument_Data >(internalId, CID) );
其中 CID 是Copied_Instrument_Data
结构变量。
后来我用:iter = InternalIdwise_Copied_Instrument_Data__Map.find("SomeKeyString");
在这样声明之后iter
:InternalIdWise_Copied_Instrument_Data::iterator iter;
然后我有:
if (iter != InternalIdwise_Copied_Instrument_Data__Map.end() )
Instrument_available = true;
if (Instrument_available == true)
{
ins_todate = *(iter).second.validToDate;
std::cout<<ins_todate;
}
然而,这不起作用。我没有得到任何数据ins_todate
。
所以,我的问题是:
如何正确访问该元素?