0

您的程序必须包含删除所有

元音和确定字符是否为元音的函数。我不断收到此错误

main.cpp:43:19: 错误:没有可行的重载 '=' novwels[100] = remove(name[100]); *
 *
 *
 *
 *
 */
#include <cstdlib>
#include <iostream>
#include <iomanip>
#include <string>

using namespace std;
void remove(string name);
bool check(string letter);

int main()

{
   string novowels[100];
   string name[100];
   cout << "Please insert a string: ";
   getline(cin, name[100]);
   novowels[100] = remove(name[100]);  //ERROR IS HERE!!!
   cout << "\n This is your string without vowels homie:\n " << novowels;

   return 0;
}

string remove(string name[100]) {
   int j = 0;
   bool trueorfalse;
   string novowels[100];
   for (int i = 0; i < 99; i++) {
      trueorfalse = check(name[i]);
      if (trueorfalse == false) {
         novowels[j] = name[i];
         j++;
      } else if (trueorfalse == true) {

      } else {
         break;
      }

   }
   return novowels[100];
}

bool check(string letter) {

   if (letter == "a" || letter == "e" || letter == "i" || letter == "o" ||     letter == "u" || letter == "A" || letter == "E" || letter == "I" || letter == "O" || letter == "U") {
      return true;
   } else {
      return false;
   }
}
4

1 回答 1

0

= 运算符不能将 void 值分配给整数或字符串或 ...

因为你的 remove 不会返回任何你不能在赋值右侧使用这个函数的东西。

于 2015-04-27T04:47:49.380 回答