multimap奇怪错误

 

 

 

这段代码就是模仿书上写的。但是就是编译通不过,一大堆编译错误,编译错误如下:

 

 

 

1>------ Build started: Project: DialogTest, Configuration: Debug Win32 ------

1>Compiling...

1>DialogTestDlg.cpp

1>c:/program files/microsoft visual studio 9.0/vc/include/functional(143) : error C2784: 'bool std::operator <(const std::_Tree<_Traits> &,const std::_Tree<_Traits> &)' : could not deduce template argument for 'const std::_Tree<_Traits> &' from 'const std::string'

1>        c:/program files/microsoft visual studio 9.0/vc/include/xtree(1466) : see declaration of 'std::operator <'

1>        c:/program files/microsoft visual studio 9.0/vc/include/functional(142) : while compiling class template member function 'bool std::less<_Ty>::operator ()(const _Ty &,const _Ty &) const'

1>        with

1>        [

1>            _Ty=std::string

1>        ]

1>        c:/program files/microsoft visual studio 9.0/vc/include/map(68) : see reference to class template instantiation 'std::less<_Ty>' being compiled

1>        with

1>        [

1>            _Ty=std::string

1>        ]

1>        c:/program files/microsoft visual studio 9.0/vc/include/xtree(22) : see reference to class template instantiation 'std::_Tmap_traits<_Kty,_Ty,_Pr,_Alloc,_Mfl>' being compiled

1>        with

1>        [

1>            _Kty=std::string,

1>            _Ty=std::string,

1>            _Pr=std::less<std::string>,

1>            _Alloc=std::allocator<std::pair<const std::string,std::string>>,

1>            _Mfl=true

1>        ]

1>        c:/program files/microsoft visual studio 9.0/vc/include/xtree(63) : see reference to class template instantiation 'std::_Tree_nod<_Traits>' being compiled

1>        with

1>        [

1>            _Traits=std::_Tmap_traits<std::string,std::string,std::less<std::string>,std::allocator<std::pair<const std::string,std::string>>,true>

1>        ]

1>        c:/program files/microsoft visual studio 9.0/vc/include/xtree(89) : see reference to class template instantiation 'std::_Tree_ptr<_Traits>' being compiled

1>        with

1>        [

1>            _Traits=std::_Tmap_traits<std::string,std::string,std::less<std::string>,std::allocator<std::pair<const std::string,std::string>>,true>

1>        ]

1>        c:/program files/microsoft visual studio 9.0/vc/include/xtree(107) : see reference to class template instantiation 'std::_Tree_val<_Traits>' being compiled

1>        with

1>        [

1>            _Traits=std::_Tmap_traits<std::string,std::string,std::less<std::string>,std::allocator<std::pair<const std::string,std::string>>,true>

1>        ]

1>        c:/program files/microsoft visual studio 9.0/vc/include/map(203) : see reference to class template instantiation 'std::_Tree<_Traits>' being compiled

1>        with

1>        [

1>            _Traits=std::_Tmap_traits<std::string,std::string,std::less<std::string>,std::allocator<std::pair<const std::string,std::string>>,true>

1>        ]

1>        c:/documents and settings/admin/デスクトップ/vs 2008 test/dialogtest/dialogtest/dialogtestdlg.cpp(166) : see reference to class template instantiation 'std::multimap<_Kty,_Ty>' being compiled

1>        with

1>        [

1>            _Kty=std::string,

1>            _Ty=std::string

1>        ]

1>c:/program files/microsoft visual studio 9.0/vc/include/functional(143) : error C2784: 'bool std::operator <(const std::_Tree<_Traits> &,const std::_Tree<_Traits> &)' : could not deduce template argument for 'const std::_Tree<_Traits> &' from 'const std::string'

1>        c:/program files/microsoft visual studio 9.0/vc/include/xtree(1466) : see declaration of 'std::operator <'

1>c:/program files/microsoft visual studio 9.0/vc/include/functional(143) : error C2784: 'bool std::operator <(const std::_Tree<_Traits> &,const std::_Tree<_Traits> &)' : could not deduce template argument for 'const std::_Tree<_Traits> &' from 'const std::string'

1>        c:/program files/microsoft visual studio 9.0/vc/include/xtree(1466) : see declaration of 'std::operator <'

1>c:/program files/microsoft visual studio 9.0/vc/include/functional(143) : error C2784: 'bool std::operator <(const std::_Tree<_Traits> &,const std::_Tree<_Traits> &)' : could not deduce template argument for 'const std::_Tree<_Traits> &' from 'const std::string'

1>        c:/program files/microsoft visual studio 9.0/vc/include/xtree(1466) : see declaration of 'std::operator <'

1>c:/program files/microsoft visual studio 9.0/vc/include/functional(143) : error C2784: 'bool std::operator <(const std::queue<_Ty,_Container> &,const std::queue<_Ty,_Container> &)' : could not deduce template argument for 'const std::queue<_Ty,_Container> &' from 'const std::string'

1>        c:/program files/microsoft visual studio 9.0/vc/include/queue(107) : see declaration of 'std::operator <'

1>c:/program files/microsoft visual studio 9.0/vc/include/functional(143) : error C2784: 'bool std::operator <(const std::queue<_Ty,_Container> &,const std::queue<_Ty,_Container> &)' : could not deduce template argument for 'const std::queue<_Ty,_Container> &' from 'const std::string'

1>        c:/program files/microsoft visual studio 9.0/vc/include/queue(107) : see declaration of 'std::operator <'

1>c:/program files/microsoft visual studio 9.0/vc/include/functional(143) : error C2784: 'bool std::operator <(const std::queue<_Ty,_Container> &,const std::queue<_Ty,_Container> &)' : could not deduce template argument for 'const std::queue<_Ty,_Container> &' from 'const std::string'

1>        c:/program files/microsoft visual studio 9.0/vc/include/queue(107) : see declaration of 'std::operator <'

1>c:/program files/microsoft visual studio 9.0/vc/include/functional(143) : error C2784: 'bool std::operator <(const std::queue<_Ty,_Container> &,const std::queue<_Ty,_Container> &)' : could not deduce template argument for 'const std::queue<_Ty,_Container> &' from 'const std::string'

1>        c:/program files/microsoft visual studio 9.0/vc/include/queue(107) : see declaration of 'std::operator <'

1>c:/program files/microsoft visual studio 9.0/vc/include/functional(143) : error C2784: 'bool std::operator <(const std::stack<_Ty,_Container> &,const std::stack<_Ty,_Container> &)' : could not deduce template argument for 'const std::stack<_Ty,_Container> &' from 'const std::string'

1>        c:/program files/microsoft visual studio 9.0/vc/include/stack(94) : see declaration of 'std::operator <'

1>c:/program files/microsoft visual studio 9.0/vc/include/functional(143) : error C2784: 'bool std::operator <(const std::stack<_Ty,_Container> &,const std::stack<_Ty,_Container> &)' : could not deduce template argument for 'const std::stack<_Ty,_Container> &' from 'const std::string'

1>        c:/program files/microsoft visual studio 9.0/vc/include/stack(94) : see declaration of 'std::operator <'

1>c:/program files/microsoft visual studio 9.0/vc/include/functional(143) : error C2784: 'bool std::operator <(const std::stack<_Ty,_Container> &,const std::stack<_Ty,_Container> &)' : could not deduce template argument for 'const std::stack<_Ty,_Container> &' from 'const std::string'

1>        c:/program files/microsoft visual studio 9.0/vc/include/stack(94) : see declaration of 'std::operator <'

1>c:/program files/microsoft visual studio 9.0/vc/include/functional(143) : error C2784: 'bool std::operator <(const std::stack<_Ty,_Container> &,const std::stack<_Ty,_Container> &)' : could not deduce template argument for 'const std::stack<_Ty,_Container> &' from 'const std::string'

1>        c:/program files/microsoft visual studio 9.0/vc/include/stack(94) : see declaration of 'std::operator <'

1>c:/program files/microsoft visual studio 9.0/vc/include/functional(143) : error C2784: 'bool std::operator <(const std::deque<_Ty,_Alloc> &,const std::deque<_Ty,_Alloc> &)' : could not deduce template argument for 'const std::deque<_Ty,_Alloc> &' from 'const std::string'

1>        c:/program files/microsoft visual studio 9.0/vc/include/deque(1354) : see declaration of 'std::operator <'

1>c:/program files/microsoft visual studio 9.0/vc/include/functional(143) : error C2784: 'bool std::operator <(const std::deque<_Ty,_Alloc> &,const std::deque<_Ty,_Alloc> &)' : could not deduce template argument for 'const std::deque<_Ty,_Alloc> &' from 'const std::string'

1>        c:/program files/microsoft visual studio 9.0/vc/include/deque(1354) : see declaration of 'std::operator <'

1>c:/program files/microsoft visual studio 9.0/vc/include/functional(143) : error C2784: 'bool std::operator <(const std::deque<_Ty,_Alloc> &,const std::deque<_Ty,_Alloc> &)' : could not deduce template argument for 'const std::deque<_Ty,_Alloc> &' from 'const std::string'

1>        c:/program files/microsoft visual studio 9.0/vc/include/deque(1354) : see declaration of 'std::operator <'

1>c:/program files/microsoft visual studio 9.0/vc/include/functional(143) : error C2784: 'bool std::operator <(const std::deque<_Ty,_Alloc> &,const std::deque<_Ty,_Alloc> &)' : could not deduce template argument for 'const std::deque<_Ty,_Alloc> &' from 'const std::string'

1>        c:/program files/microsoft visual studio 9.0/vc/include/deque(1354) : see declaration of 'std::operator <'

1>c:/program files/microsoft visual studio 9.0/vc/include/functional(143) : error C2784: 'bool std::operator <(const std::vector<_Ty,_Alloc> &,const std::vector<_Ty,_Alloc> &)' : could not deduce template argument for 'const std::vector<_Ty,_Alloc> &' from 'const std::string'

1>        c:/program files/microsoft visual studio 9.0/vc/include/vector(1320) : see declaration of 'std::operator <'

1>c:/program files/microsoft visual studio 9.0/vc/include/functional(143) : error C2784: 'bool std::operator <(const std::vector<_Ty,_Alloc> &,const std::vector<_Ty,_Alloc> &)' : could not deduce template argument for 'const std::vector<_Ty,_Alloc> &' from 'const std::string'

1>        c:/program files/microsoft visual studio 9.0/vc/include/vector(1320) : see declaration of 'std::operator <'

1>c:/program files/microsoft visual studio 9.0/vc/include/functional(143) : error C2784: 'bool std::operator <(const std::vector<_Ty,_Alloc> &,const std::vector<_Ty,_Alloc> &)' : could not deduce template argument for 'const std::vector<_Ty,_Alloc> &' from 'const std::string'

1>        c:/program files/microsoft visual studio 9.0/vc/include/vector(1320) : see declaration of 'std::operator <'

1>c:/program files/microsoft visual studio 9.0/vc/include/functional(143) : error C2784: 'bool std::operator <(const std::vector<_Ty,_Alloc> &,const std::vector<_Ty,_Alloc> &)' : could not deduce template argument for 'const std::vector<_Ty,_Alloc> &' from 'const std::string'

1>        c:/program files/microsoft visual studio 9.0/vc/include/vector(1320) : see declaration of 'std::operator <'

1>c:/program files/microsoft visual studio 9.0/vc/include/functional(143) : error C2784: 'bool std::operator <(const std::reverse_iterator<_RanIt> &,const std::reverse_iterator<_RanIt2> &)' : could not deduce template argument for 'const std::reverse_iterator<_RanIt> &' from 'const std::string'

1>        c:/program files/microsoft visual studio 9.0/vc/include/xutility(2236) : see declaration of 'std::operator <'

1>c:/program files/microsoft visual studio 9.0/vc/include/functional(143) : error C2784: 'bool std::operator <(const std::reverse_iterator<_RanIt> &,const std::reverse_iterator<_RanIt2> &)' : could not deduce template argument for 'const std::reverse_iterator<_RanIt> &' from 'const std::string'

1>        c:/program files/microsoft visual studio 9.0/vc/include/xutility(2236) : see declaration of 'std::operator <'

1>c:/program files/microsoft visual studio 9.0/vc/include/functional(143) : error C2784: 'bool std::operator <(const std::reverse_iterator<_RanIt> &,const std::reverse_iterator<_RanIt2> &)' : could not deduce template argument for 'const std::reverse_iterator<_RanIt> &' from 'const std::string'

1>        c:/program files/microsoft visual studio 9.0/vc/include/xutility(2236) : see declaration of 'std::operator <'

1>c:/program files/microsoft visual studio 9.0/vc/include/functional(143) : error C2784: 'bool std::operator <(const std::reverse_iterator<_RanIt> &,const std::reverse_iterator<_RanIt2> &)' : could not deduce template argument for 'const std::reverse_iterator<_RanIt> &' from 'const std::string'

1>        c:/program files/microsoft visual studio 9.0/vc/include/xutility(2236) : see declaration of 'std::operator <'

1>c:/program files/microsoft visual studio 9.0/vc/include/functional(143) : error C2784: 'bool std::operator <(const std::_Revranit<_RanIt,_Base> &,const std::_Revranit<_RanIt2,_Base2> &)' : could not deduce template argument for 'const std::_Revranit<_RanIt,_Base> &' from 'const std::string'

1>        c:/program files/microsoft visual studio 9.0/vc/include/xutility(2046) : see declaration of 'std::operator <'

1>c:/program files/microsoft visual studio 9.0/vc/include/functional(143) : error C2784: 'bool std::operator <(const std::_Revranit<_RanIt,_Base> &,const std::_Revranit<_RanIt2,_Base2> &)' : could not deduce template argument for 'const std::_Revranit<_RanIt,_Base> &' from 'const std::string'

1>        c:/program files/microsoft visual studio 9.0/vc/include/xutility(2046) : see declaration of 'std::operator <'

1>c:/program files/microsoft visual studio 9.0/vc/include/functional(143) : error C2784: 'bool std::operator <(const std::_Revranit<_RanIt,_Base> &,const std::_Revranit<_RanIt2,_Base2> &)' : could not deduce template argument for 'const std::_Revranit<_RanIt,_Base> &' from 'const std::string'

1>        c:/program files/microsoft visual studio 9.0/vc/include/xutility(2046) : see declaration of 'std::operator <'

1>c:/program files/microsoft visual studio 9.0/vc/include/functional(143) : error C2784: 'bool std::operator <(const std::_Revranit<_RanIt,_Base> &,const std::_Revranit<_RanIt2,_Base2> &)' : could not deduce template argument for 'const std::_Revranit<_RanIt,_Base> &' from 'const std::string'

1>        c:/program files/microsoft visual studio 9.0/vc/include/xutility(2046) : see declaration of 'std::operator <'

1>c:/program files/microsoft visual studio 9.0/vc/include/functional(143) : error C2784: 'bool std::operator <(const std::pair<_Ty1,_Ty2> &,const std::pair<_Ty1,_Ty2> &)' : could not deduce template argument for 'const std::pair<_Ty1,_Ty2> &' from 'const std::string'

1>        c:/program files/microsoft visual studio 9.0/vc/include/utility(84) : see declaration of 'std::operator <'

1>c:/program files/microsoft visual studio 9.0/vc/include/functional(143) : error C2784: 'bool std::operator <(const std::pair<_Ty1,_Ty2> &,const std::pair<_Ty1,_Ty2> &)' : could not deduce template argument for 'const std::pair<_Ty1,_Ty2> &' from 'const std::string'

1>        c:/program files/microsoft visual studio 9.0/vc/include/utility(84) : see declaration of 'std::operator <'

1>c:/program files/microsoft visual studio 9.0/vc/include/functional(143) : error C2784: 'bool std::operator <(const std::pair<_Ty1,_Ty2> &,const std::pair<_Ty1,_Ty2> &)' : could not deduce template argument for 'const std::pair<_Ty1,_Ty2> &' from 'const std::string'

1>        c:/program files/microsoft visual studio 9.0/vc/include/utility(84) : see declaration of 'std::operator <'

1>c:/program files/microsoft visual studio 9.0/vc/include/functional(143) : error C2784: 'bool std::operator <(const std::pair<_Ty1,_Ty2> &,const std::pair<_Ty1,_Ty2> &)' : could not deduce template argument for 'const std::pair<_Ty1,_Ty2> &' from 'const std::string'

1>        c:/program files/microsoft visual studio 9.0/vc/include/utility(84) : see declaration of 'std::operator <'

1>c:/program files/microsoft visual studio 9.0/vc/include/functional(143) : error C2676: binary '<' : 'const std::string' does not define this operator or a conversion to a type acceptable to the predefined operator

1>Build log was saved at "file://c:/Documents and Settings/Admin/デスクトップ/VS 2008 TEST/DialogTest/DialogTest/Debug/BuildLog.htm"

1>DialogTest - 33 error(s), 0 warning(s)

========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

 

看的我头大啊。。哪么简单的几句话,怎么可能有那么多错误呐。经过google(goolge真是好东西啊),原来是没有#include<string>的问题。以前一直认为有了#include<iostream>就不用#include<string>了呐。问题解决以后,为了弄懂为什么,就再次google(再次赞美一下,google真nice),发现如下结论:

 

1,<string>是包装了std的C++头文件,对应的是新的strng类.
2,<iostream>是包含输入/输出流处理的头文件.

 

哦对了。带.h和不带.h可是有很大区别哟。。<string.h>是旧的C头文件,对应的是基于char*的字符串处理函数;
C++中新定义的方法都是有名字空间的 比如cout就属于std名字空间 如果include头文件的时候加上.h,默认会using namespace 否则需要自己加上 using namespace XXX 对于C中已经定义的方法如printf,没有影响的

iostream.h是包含输入/输出流处理的头文件,iostream就什么都不是了
但用iostream要加名词空间namespace

#include<iostream.h>
或者是
#include<iostream>
using namespace std;
二者都行

#include<iostream.h>是C语言中比较通用的
#include<iostream>
using namespace std;
是C++中比较通用的
当然这种转变不是一个人一拍脑袋想出来的啦,故事很曲折,,,也很能反映C和C++这个语言的区别和历史,有兴趣的同学可以自己google一下。

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值