嘿,我有一个结构
typedef struct CLUSTERINFO{
unsigned cluster;
vector <string> scopids;
}clusterinfo;
看起来我有一些问题将值分配给向量 scopids 然后打印出来
multimap<unsigned, clusterinfo> classinfomap;
clusterinfo clinfo;
string id_req;
//vector<unsigned> cluster_req_list and clustersipinfomap are some known from previous modules
for (ib=cluster_req_list.begin(); ib !=cluster_req_list.end(); ib++)
{
if(clustersipinfomap.count(*ib)>0)
{
cout<<count1<<"\t"<<*ib<<"\t";
clinfo.cluster= *ib;
std::pair<multimap<unsigned,sipinfo>::iterator, multimap<unsigned,sipinfo>::iterator> ret;
set<string>id_req_list;
id_req_list.clear();
ret=clustersipinfomap.equal_range(*ib);
//obtain the id_req_list
for (multimap<unsigned, sipinfo>:: iterator ic=ret.first; ic!=ret.second; ++ic)
{
string id_tmp=ic->second.id;
id_req_list.insert(id_tmp);
*****(clinfo.scopids).push_back(id_tmp); //i got sth wrong here
}
再次打印出结构中的向量是错误的;
multimap<unsigned, clusterinfo>::iterator ip;
for(ip= classinfomap.begin(); ip!=classinfomap.end(); ip ++)
{
cout<<ip->first <<"\t"<< ip->second.cluster<<endl;
for (unsigned it=0; it< (ip->second.scopids).size(); it++)
{
count<< (ip->second.scopids)[it] << endl;
}
}