My dylan::Replace() function supposed to take a string as the parameter, replace the spaces with asterisks ('*') and return a string. The code below is what I have:
#define n 0
namespace dylan{
string Replace(string);
string Replace (string s){
if (s.substr(n)=="")
cout << "string is empty \n";
else
s.replace(s.begin(),s.end(),' ','*');
return s;
}
}
using namespace dylan;
int main (int argc, char * argv[]){
string s="a b c";
string sAfter=Replace(s);
// some more stuff
}
But G++ tells me that within dylan::Replace() there is no matching function for call to std::basic_string<CharT,_Traits,_Alloc>replace(...)
BONUS POINT: are there any recursive ways to do the same job (replace a certain character in a string)?
QUESTION UPDATED: I modified and ran the program and it doe not do the job I wanted. Instead it printed asterisks multiple times.