大佬教程收集整理的这篇文章主要介绍了使用“+”附加 2 个字符串时出现 C++ C2676 错误,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
Error C2676 binary '+': 'std::string' does not @R_403_5552@ this operator or a conversion to a type acceptable to the predefined operator
我在尝试附加两个字符串时收到 C2676 错误。我已经尝试了所有我能想到的方法,但没有成功。
包含和使用代码如下。
#pragma once
#include <String>
#include <iostream>
#include <windows.h>
#include <stdlib.h>
#include <tchar.h>
#include <stream>
#include <cstdlib>
#include <conio.h>
//#include <winnt.h>
//#include <WinUser.h>
using namespace std;
using std::string;
using std::wString;
namespace CppCLRWinformsProjekt {
using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::windows::Forms;
using namespace System::Data;
using namespace System::Drawing;
using namespace std;
给我带来麻烦的代码是。
private: System::VoID bntSELEcted_Click(System::Object^ sender,System::EventArgs^ E) {
int numSELEcted = this->checkedListBox1->checkedItems->Count;
if (numSELEcted != 0)
{
// Set input focus to the List Box.
//SetFocus(lstReceiver);
String s = "";
// If so,loop through all checked items and print results.
for (int x = 0; x < numSELEcted; x++)
{
// it appears that the first "+" sign is what is giving me trouble
s = s + lstReceiver + (x + 1).ToString() + " = " + this->checkedListBox1->checkedItems[x]->ToString() + "\n";
}
this.lstReceiver.Items.Add(s);
}
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)
以上是大佬教程为你收集整理的使用“+”附加 2 个字符串时出现 C++ C2676 错误全部内容,希望文章能够帮你解决使用“+”附加 2 个字符串时出现 C++ C2676 错误所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。