C++ 调试在Visual Studio中找不到'='运算符

C++ Debugging no '=' operator found in Visual Studio

本文关键字:运算符 找不到 调试 Visual Studio C++      更新时间:2023-10-16

Visual Studio在我尝试编译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.0vcincludeutility
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类型:"const std::string"

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

相关文章: