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

关于map中有关问题

2012-02-10 
关于map中问题首先我定义了一个map对象map string,loc**word_map其中loc的定义如下:typedefvector loc

关于map中问题
首先我定义了一个map对象
map <string,   loc   *>   *word_map   ;

其中loc的定义如下:
typedef   vector <location>   loc

然后
word_map   =   new   map <string,   loc   *>   ;
这样编译会有212个warns,有点多,不知道是为什么,
下面是一个warn
warning   C4786:   'std::_Tree <std::basic_string <char,std::char_traits <char> ,std::allocator <char>   > ,std::pair <std::basic_string <char,std::char_traits <char> ,std::allocator <char>   >   const   ,std::vector <std::pair <short,short> ,std::allocator <std::pair <short,s
hort>   >   >   *> ,std::map <std::basic_string <char,std::char_traits <char> ,std::allocator <char>   > ,std::vector <std::pair <short,short> ,std::allocator <std::pair <short,short>   >   >   *,std::less <std::basic_string <char,std::char_traits <char> ,std::allocator <char>   >  
> ,std::allocator <std::vector <std::pair <short,short> ,std::allocator <std::pair <short,short>   >   >   *>   > ::_Kfn,std::less <std::basic_string <char,std::char_traits <char> ,std::allocator <char>   >   > ,std::allocator <std::vector <std::pair <short,short> ,std::allocato
r <std::pair <short,short>   >   >   *>   > ::_Redbl '   :   identifier   was   truncated   to   '255 '   characters   in   the   debug   information

于是我改为
map <string,   loc   *,   less <string> ,   allocator>   *word_map   ;
其中loc的定义不变
然后
word_map   =   new   map <string,   loc   *,   less <string> ,   allocator>   ;
可是这样warning少了,但是有错误,错误如下,  

F:\c++\wrok\练习\C++   primer练习\单词查询系统\完整程序.cpp(55)   :   error   C2955:   'allocator '   :   use   of   class   template   requires   template   argument   list
                c:\program   files\microsoft   visual   studio\vc98\include\xmemory(72)   :   see   declaration   of   'allocator '
F:\c++\wrok\练习\C++   primer练习\单词查询系统\完整程序.cpp(134)   :   error   C2955:   'allocator '   :   use   of   class   template   requires   template   argument   list
                c:\program   files\microsoft   visual   studio\vc98\include\xmemory(72)   :   see   declaration   of   'allocator '
F:\c++\wrok\练习\C++   primer练习\单词查询系统\完整程序.cpp(134)   :   error   C2512:   'map <class   std::basic_string <char,struct   std::char_traits <char> ,class   std::allocator <char>   > ,class   std::vector <struct   std::pair <short,short> ,class   std::allocator <struct   st
d::pair <short,short>   >   >   *,struct   std::less <class   std::basic_string <char,struct   std::char_traits <char> ,class   std::allocator <char>   >   > ,class   std::allocator> '   :   no   appropriate   default   constructor   available

请有耐心看完的朋友指教,多谢!




[解决办法]
加#pragma warning(disable:4786)在所有的h文件的最前面,就不会有那个4786的warning了

热点排行