为什么我得到' replace '没有在这个范围错误中声明
why i got ‘replace’ was not declared in this scope error?
我想为我的代码使用替换来检测回文,这是它的一部分
cout<<isPalindrome("Won't I panic in a pit now?")<<endl;
bool PalindromeFinder::isPalindrome(string input){
char chars[] = {' ' , ''' , '?' , '!' , ','};
for (int i=0; i<input.length(); i++) {
replace(input.begin(), input.end(), chars[i], ' ');
}
它给我正确的结果是wontipanicinapitnow
但是当我运行函数时,它给了我' replace '没有在这个范围内声明。任何建议吗?
你没有写#include <algorithm>
,也没有写std::replace
。
文档是你的朋友。
相关文章:
- 错误:未在此范围内声明'reverse'
- 在基于范围的for循环中使用结构化绑定声明
- 错误:"imread"未在此范围内声明
- 我在范围内未声明的错误类有问题
- 未在此范围内声明错误 'xy'
- Socklen_t未在此范围内声明
- 如何从未知视图中声明范围::v3::View 变量
- 错误:'[' 之前预期的非限定 id 和错误:'users'未在此范围内声明
- "Main"已在当前范围内声明
- c++ 变量在宏的扩展中没有在这个范围内声明
- 朋友声明的复杂范围界定规则有什么意义?
- C++ 在编译过程中 strtok 函数 Eclipse 说没有在范围内声明?
- 'num1'未在此范围内声明
- 在此范围内未声明错误"Clreol"
- 如何找到在本地范围内声明的变量的地址?
- 简化在 Pybind11 中为 C++ 模板类生成包装类:模板声明不能出现在块范围内
- "myClock"未在此范围错误中声明
- NT状态未在此范围内声明
- 通过引用将循环计数器或范围声明传递给线程有什么区别
- 带有 extern 和没有 extern 的函数的本地/块范围声明之间的区别