变量或字段“ letterGrade”声明为无效。该错误消息出现在函数“ letterGrade”的最后一次迭代中。有人知道为什么吗?

#include <string>
#include <iostream>
using namespace std;
void letterGrade (int score, string& scoreLetter);
string scoreLetter;
int main()
{
    int score;
    char A, B, C, D, F;
    cout<<"Enter the grade: ";
    cin>> score;
    letterGrade (score, scoreLetter);
    cout<<"The letter grade is a(n) "<< scoreLetter<<".";
    system ("pause");
    return 0;
}
void letterGrade (score, scoreLetter)
{
     for (score >= 90)
     {
             scoreLetter = 'A';}
      if (score == 100)
     {
             scoreLetter.insert (1, "+");
     }
     else if (8<=score% 10 && score% 10 <= 9)
     {
                   scoreLetter.insert (1, "+");
     else if (0<=score% 10 && score% 10 <=1)
     {
                   scoreLetter.insert (1, "-");
     }

最佳答案

您没有在letterGrade定义的参数上命名类型。

10-04 13:44