STL map 报错:error C2143: syntax error : missing ';' before '<'
#ifndef __P35_H__
#define __P35_H__
#include <IOSTREAM>
#include <MAP>
#include <algorithm>
struct CidToId
{
int cid;
int cmt;//cid make time
};
CidToId cidtoid;
typedef map <int, cidtoid> Map_CidToServerId;
typedef map <int, Map_CidToServerId> Map_TidToCid;
Map_TidToCid map_tidtocid;
Map_TidToCid::iterator it_tidtocid;
Map_CidToServerId::iterator it_cidtoserverid;
InsertTid(int tid, int cid);
#endif
InsertTid(int tid, int cid, int sip)stl map algorithm struct c
{
int i = 0;
if(map_tidtocid.end() == (it_tidtocid = map_tidtocid.find(tid)))//tid find fail
{
map_tidtocid[tid];//insert tid
it_tidtocid = map_tidtocid.find(tid);//iterator
}
if(it_tidtocid->second.end() == (it_cidtoserverid = it_tidtocid->second.find(sip)))//find cid fail
{
it_tidtocid->second[sip];//insert cid
it_cidtoserverid = it_tidtocid->second.find(sip);
it_cidtoserverid->second.cid = cid;
it_cidtoserverid->second.cmt = (int)time(NULL);
}
else
{
it_cidtoserverid->second.cid = cid;
it_cidtoserverid->second.cmt = (int)time(NULL);
}
}
#ifndef __P35_H__
#define __P35_H__
//#include <IOSTREAM>
//#include <MAP>
#include <iostream>
#include <map>
#include <algorithm>
using std::map;
.....
#ifndef __P35_H__
#define __P35_H__
#include <IOSTREAM>
#include <MAP>
#include <algorithm>
struct CidToId
{
int cid;
int cmt;//cid make time
};
CidToId cidtoid;
typedef map <int, CidToId> Map_CidToServerId;
typedef map <int, Map_CidToServerId> Map_TidToCid;
Map_TidToCid map_tidtocid;
Map_TidToCid::iterator it_tidtocid;
Map_CidToServerId::iterator it_cidtoserverid;
void InsertTid(int tid, int cid);
#endif
void InsertTid(int tid, int cid, int sip)
{
int i = 0;
if(map_tidtocid.end() == (it_tidtocid = map_tidtocid.find(tid)))//tid find fail
{
map_tidtocid[tid];//insert tid
it_tidtocid = map_tidtocid.find(tid);//iterator
}
if(it_tidtocid->second.end() == (it_cidtoserverid = it_tidtocid->second.find(sip)))//find cid fail
{
it_tidtocid->second[sip];//insert cid
it_cidtoserverid = it_tidtocid->second.find(sip);
it_cidtoserverid->second.cid = cid;
it_cidtoserverid->second.cmt = (int)time(NULL);
}
else
{
it_cidtoserverid->second.cid = cid;
it_cidtoserverid->second.cmt = (int)time(NULL);
}
return;
}
//typedef map <int, int> Map_CidToServerId;
typedef std::map <int, int> Map_CidToServerId;
typedef std::map <int, CidToId> Map_CidToServerId;