【发布时间】:2017-01-03 14:15:55
【问题描述】:
当我尝试编译我的 C++ 项目时,Visual Studio 给了我这个错误:
Severity: Error
Code: C2678
Description: binary '=': no operator found which takes a left-hand operand of type 'const std::string' (or there is no acceptable conversion)
Project: jr
File: c:\program files (x86)\microsoft visual studio 14.0\vc\include\utility
Line: 192
我想,在我的项目中,我正在尝试更改常量字符串。 我如何找到这个?如何调试此类错误?
错误中提到的文件名和行是微软的一些只读文件。 我想找出我的代码中的错误。这是第 192 行代码的摘录:
_Myt& operator=(const _Myt& _Right)
{ // assign from copied pair
first = _Right.first;
second = _Right.second;
return (*this);
}
【问题讨论】:
-
你为什么不告诉我们第 192 行错误在哪里。
-
“某处”是
Line: 192吗? -
如果是编译错误,Visual Studio 会为您轻松突出显示
-
双击错误列表或输出窗口中的错误消息会将您带到有问题的行。
-
查看输出选项卡而不是错误列表。将会有一个完整的消息序列,从一个关于
operator=的消息开始。向下滚动,直到您在自己的代码中找到有问题的位置。 (错误列表是垃圾。)
标签: c++ visual-studio