CMap

#include <afxtempl.h>
CMap<DWORD,DWORD&,COLORREF,COLORREF&> MapItemColor;

编译时出错:
#include <map> 
map <int,int> mymap; 
出错如下: 
: error C2143: syntax error : missing ';' before ' <' 
: error C2501: 'map' : missing storage-class or type specifiers 
: error C2059: syntax error : ' <' 
: error C2238: unexpected token(s) preceding ';' 

真的该怀疑下我的编译器么?


-------------------------------------------
你这种引用方法是不对的。
使用CMap最正确的引用方式是引用#include <afxtempl.h>
而且我刚才用我的MFC工程按照你的方式做了一下,是不存在编译方面的问题的。
我发觉你问题的原因是对afxtempl.h这个里面的内容识别上有编译错误,而导致这种错误的原因应该出现在#include <afxtempl.h>这个头文件引用的前面的头文件,有一个分号的缺失。或者其他失误,而导致了#include <afxtempl.h> 这个里面的编译错误,你自己仔细看看。
你可以新建一个空的工程,里面就添加一个#include <afxtempl.h> 
,然后声明一个成员变量。
private:
      CMap<DWORD, DWORD&, COLORREF, COLORREF&>m_MapItemColor;

posted @ 2015-12-24 10:32  星雷热忱  阅读(439)  评论(0编辑  收藏  举报