首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > VC/MFC >

奇怪的error C2143异常

2012-01-19 
奇怪的error C2143错误#includemap#includestring#includealgorithm#includestdlib.h#includeicp

奇怪的error C2143错误
#include   <map>
#include   <string>
#include   <algorithm>
#include   <stdlib.h>
#include   "icp.h "

//---------------------------------------------

enum   DeviceType{   thermometer,   thermostat   };

struct   DeviceState{                                             //State   for   a   device
              DeviceType         type;
      const   char   *     model;
      std::string       location;
      short                   nominal_temp;               //For   thermostats   only
};

typedef   map <unsigned   long,   DeviceState>   StateMap;
。。。
static   StateMap   dstate;  

编译信息:
C:\test\IDL_TEST\icp.cpp(18)   :   error   C2143:   syntax   error   :   missing   '; '   before   ' < '
C:\test\IDL_TEST\icp.cpp(18)   :   error   C2143:   syntax   error   :   missing   '; '   before   ' < '
C:\test\IDL_TEST\icp.cpp(27)   :   error   C2146:   syntax   error   :   missing   '; '   before   identifier   'dstate '
C:\test\IDL_TEST\icp.cpp(27)   :   fatal   error   C1004:   unexpected   end   of   file   found
请高手帮忙解答一下

[解决办法]
似乎是map没有用std
这样可以编译过去
#include <string>
#include <map>

using namespace std;

enum DeviceType{ thermometer, thermostat };

struct DeviceState{ //State for a device
DeviceType type;
const char * model;
std::string location;
short nominal_temp; //For thermostats only
};

typedef std::map <unsigned long, DeviceState> StateMap;

static StateMap dstate;
int main()
{
}

热点排行