Итак, я писал функцию для удаления всех гласных в строке, и я продолжал получать эту ошибку:
pa07.cpp:138:39: error: non-const lvalue reference to type 'std::string'
(aka 'basic_string<char>') cannot bind to a value of unrelated type
'const char [12]'
cout << csutilities::removeVowels("Hello wOrld") << endl;
^~~~~~~~~~~~~
pa07.cpp:110:39: note: passing argument to parameter 'str' here
std::string removeVowels(std::string& str)
Я не совсем понимаю, если кто-то может объяснить это, поэтому яне буду делать это снова, это было бы удивительно.Спасибо за любую помощь!
std::string removeVowels(std::string& str)
{
string newWord = "";
for(unsigned int x = 0; x < str.length(); x++)
{
if (str[x] == ('A') || str[x] == ('a') ||
str[x] == ('E') || str[x] == ('e') ||
str[x] == ('I') || str[x] == ('i') ||
str[x] == ('O') || str[x] == ('o') ||
str[x] == ('U') || str[x] == ('u'))
newWord = newWord + "";
else
newWord = newWord + str[x];
}//for statement to determine vowel
return newWord;
}//function to remove vowels
Нужно просто удалить гласные в строке, спасибо за ваше время.