简体   繁体   English

为什么我没有在此范围错误中声明“替换”?

[英]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.

相关问题 为什么我会收到“未在此范围内声明”错误? - why am I getting a “was not declared in this scope” error? 为什么我在这个 scope 中没有声明错误? - Why i am getting error not declared in this scope? 为什么我没有在此 scope 错误中声明 - Why am I getting not declared in this scope error 为什么会出现“预期;”错误和“变量未在范围内声明”错误? - Why do I get “Expected ;” error and “Variable not declared in scope” error? 为什么我在声明本身中收到“未在范围内声明”错误? - Why am I getting a "not declared in scope" error in the declaration itself? 为什么我收到“未在该范围内声明getuid”错误? - Why I am getting “getuid was not declared in that scope” error? 我收到以下错误:错误:“名称”未在此范围内声明; 你的意思是&#39;重命名 - I got the following error : error: ‘name’ was not declared in this scope; did you mean ‘rename 我收到“错误:字符串未在此范围内声明” - I'm getting an "Error: string was not declared in this scope" 我如何解决此错误“未在此范围内声明” - How do i fix this error “was not declared in this scope” C++:当我包含标题时,为什么会出现“未在此范围内声明”错误? - C++: Why do I get a ´not declared in this scope´ error when I included the header?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM