error handling - No matching function call in C++ -


i'm getting error of 'no matching function call' ideas why? in advance.

#include <iostream> #include <string> using namespace std;  void redactdigits(string & s);  int main(int argc, const char * argv[]) {      redactdigits("hello");      return 0; }  void redactdigits(string & s){  double stringlength = 0; string copystring;   stringlength = s.size();  (int = 0; < stringlength + 1; i++) {     if (atoi(&s[i])) {         copystring.append(&s[i]);     }      else {         copystring.append("*");     }   }  s = copystring;  cout << s;   } 

you missing void in function declaration. furthermore, need pass const reference, able bind temporary:

void redactdigits(const string & s); ^^^^              ^^^^^ 

without const, call illegal:

redactdigits("hello"); 

although compilers have non-standard extensions allow non-const references bind temporaries.

edit: since attempting modify input string inside function, solution either keep original function signature , pass std::string instead of null-terminated string literal, or return std::string:

std::string redactdigits(const std::string& s) {   ...   return copystring; } 

then

std::string s = redactdigits("hello"); 

Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -