如何摆脱此错误 main.cpp:43:19: 错误:没有可行的重载 '=' novowels[100] = 删除(名称[100]);

How do I get Rid of this error main.cpp:43:19: error: no viable overloaded '=' novowels[100] = remove(name[100]);

本文关键字:错误 名称 novowels 删除 cpp main 何摆脱 重载      更新时间:2023-10-16

你的程序必须包含一个函数来删除所有

元音和函数来确定是否字符是元音。我一直收到此错误

主.cpp:43:19:错误:没有可行的重载 '=' novowels[100] = 删除(名称[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;
   }
}

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

因为您的删除不会返回任何内容,所以您无法在作业右侧使用此函数。