[英]why i got ‘replace’ was not declared in this scope error?
I wanna to use replace for my code to detect palindrome, and this is part of it我想用我的代码替换来检测回文,这是其中的一部分
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], '\0');
}
it give me the proper result which is wontipanicinapitnow它给了我正确的结果,即 wontipanicinapitnow
but when when i run the function it gave me 'replace' was not declared in this scope.但是当我运行该函数时,它给我的“替换”没有在此范围内声明。 any suggestion?有什么建议吗?
You didn't #include <algorithm>
, and you didn't write std::replace
.您没有#include <algorithm>
,也没有编写std::replace
。
The documentation is your friend.文档是您的朋友。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.