gpt4 book ai didi

c++ - 没有可行的重载 +=?

转载 作者:太空宇宙 更新时间:2023-11-04 15:18:22 24 4
gpt4 key购买 nike

有人能告诉我为什么我会收到这个“没有可行的重载”吗?我很困惑为什么我会收到这个....我是菜鸟。

int main()
{
char ch;
vector<int> temp;

ifstream infile;
infile.open("tempsF.txt");

if (infile.fail())
{
cout << "Could not open file numbers." << "\n";
return 1;
}
int data;
infile >> data;
while (!infile.eof())
{
if(isalpha(ch) || ispunct(ch))
{
if(isupper(ch) && ch != '\n')

temp += " ";<<<<<<<<<<<<<<<<<<<<<<<<< No Viable Overloaded '+='

temp += ch;<<<<<<<<<<<<<<<<<<<<<<<<<< No Viable Overloaded '+='
}
}

最佳答案

这不是您使用 std::vector<int> 的方式 .尝试更像:

temp.push_back(42);

或者您可能想要 std::vector<std::string>然后你可以:

temp.push_back(" ");

但是没有 operator +=()std::vector 定义.

关于c++ - 没有可行的重载 +=?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26070767/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com