error C2784

n911 2003-10-22 04:28:55
#include <vector>
#include <iostream>
#include <assert.h>
using namespace std;


int main()
{
string str;
string str2;

assert(str2 == str);

return 0;
}


error C2784: 'bool __cdecl std::operator ==(const class std::vector<_Ty,_A> &,const class std::vector<_Ty,_A> &)' : could not deduce template argument for 'const class std::vector<_Ty,_A> &' from 'class std::basic_strin
g<char,struct std::char_traits<char>,class std::allocator<char> >'
...全文
808 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
scatzr 2003-10-23
  • 打赏
  • 举报
回复
偶来接分
楼上的都说了:)
Andy84920 2003-10-23
  • 打赏
  • 举报
回复
楼上的说的够了!不用关注了.
yjh1982 2003-10-23
  • 打赏
  • 举报
回复
so do I
darcymei 2003-10-22
  • 打赏
  • 举报
回复
在标准头文件如<vector>或<iostream> 中声明的函数对象和类模板都被声明在名字空间std 中。但是名字空间的定义可以是不连续的,可以跨越多个文件。没包含<string>就会加载<vector>或<iostream>中的==(估计是用预处理器指示符像#ifdef之类实现的),所以就会有这种错误拉
flc 2003-10-22
  • 打赏
  • 举报
回复
关注
davidyx 2003-10-22
  • 打赏
  • 举报
回复
加 #include<string>
oyd 2003-10-22
  • 打赏
  • 举报
回复
sorry,我弄错了,我的工程中include了<string>。所以我的编译没有问题。
你只#include <vector>,所以只存在
'bool __cdecl std::operator ==(const class std::vector<_Ty,_A> &,const class std::vector<_Ty,_A> &)的定义。
当然调用std::operator ==(str2, str)时会出错啦。
oyd 2003-10-22
  • 打赏
  • 举报
回复
写错了吧,这个代码不可能产生错误

24,854

社区成员

发帖
与我相关
我的任务
社区描述
C/C++ 工具平台和程序库
社区管理员
  • 工具平台和程序库社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧