Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/sockets/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ C++;调试编号'=';在Visual Studio中找到运算符_C++_Visual Studio - Fatal编程技术网

C++ C++;调试编号'=';在Visual Studio中找到运算符

C++ C++;调试编号'=';在Visual Studio中找到运算符,c++,visual-studio,C++,Visual Studio,VisualStudio在编译C++项目时给出了这个错误: 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

VisualStudio在编译C++项目时给出了这个错误:

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           
我想,在我的项目中的某个地方,我正试图改变常量字符串。 我怎么找到这个?如何调试此类错误

错误中提到的文件名和行是Microsoft提供的一些只读文件我想在我的代码中找到错误。以下是第192行的代码摘录:

_Myt& operator=(const _Myt& _Right)
        {   // assign from copied pair
        first = _Right.first;
        second = _Right.second;
        return (*this);
        }

您可能希望编写如下代码:

const std::string s;
s = ""; 
这就是为什么错误会说关于
const
type:'const std::string'


另一种可能性是,您希望在const方法中为字符串赋值。

为什么不向我们显示错误所在的第192行。“某处”是否为
行:192
?如果是编译错误,Visual Studio将为您轻松地突出显示该错误,双击错误列表中的错误消息或“输出”窗口会将您带到有问题的行。请查看“输出”选项卡,而不是错误列表。将有一个完整的消息序列,从about
operator=
开始。向下滚动,直到在自己的代码中找到有问题的位置。(错误列表是垃圾。)