为什么c++中用map中insert的返回的iterator使用报错
intmain(intargc,char*argv[]){intm1,m2;char*filename;cout<<"pleaseenteryourgarphname:"...
int main(int argc, char *argv[])
{
int m1,m2;
char* filename;
cout<<"please enter your garph name:"<<endl;
cin>>filename;
CGraph cgraph(filename);
map<int,int> cmap;
list<CEdge*> l=cgraph.getList();
list<CEdge*>::iterator i1,i2;
i2=l.end();
pair<map<int,int>::iterator,bool> pcheck;
for(i1=l.begin();i1!=i2;i1++)
{
m1=(*i1)->getHead();
m2=(*i1)->getTail();
pair<int,int> p1(m1,1);
pair<int,int> p2(m2,1);
pcheck=cmap.insert(p1);
if(!pcheck.second)
pcheck->first.second++;
pcheck=cmap.insert(p2);
if(!pcheck)
pcheck->first.second++;
}
return 0; 展开
{
int m1,m2;
char* filename;
cout<<"please enter your garph name:"<<endl;
cin>>filename;
CGraph cgraph(filename);
map<int,int> cmap;
list<CEdge*> l=cgraph.getList();
list<CEdge*>::iterator i1,i2;
i2=l.end();
pair<map<int,int>::iterator,bool> pcheck;
for(i1=l.begin();i1!=i2;i1++)
{
m1=(*i1)->getHead();
m2=(*i1)->getTail();
pair<int,int> p1(m1,1);
pair<int,int> p2(m2,1);
pcheck=cmap.insert(p1);
if(!pcheck.second)
pcheck->first.second++;
pcheck=cmap.insert(p2);
if(!pcheck)
pcheck->first.second++;
}
return 0; 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询