C++ 错误C2679:二进制'&燃气轮机>;:未找到接受类型为';的右操作数的运算符;等级类型';
当我尝试将输入分配到“grades”数组时,我很难理解为什么会收到此错误消息。还有一条消息说“IntelliSense:no operator”>>“与这些操作数匹配,操作数类型为:std::istream>>GradeType”。任何帮助或提示请。先谢谢你C++ 错误C2679:二进制'&燃气轮机>;:未找到接受类型为';的右操作数的运算符;等级类型';,c++,arrays,input,C++,Arrays,Input,当我尝试将输入分配到“grades”数组时,我很难理解为什么会收到此错误消息。还有一条消息说“IntelliSense:no operator”>>“与这些操作数匹配,操作数类型为:std::istream>>GradeType”。任何帮助或提示请。先谢谢你 // This program will input an undetermined number of student names // and a number of grades for each student. The
// This program will input an undetermined number of student names
// and a number of grades for each student. The number of grades is
// given by the user. The grades are stored in an array.
// Two functions are called for each student.
// One function will give the numeric average of their grades.
// The other function will give a letter grade to that average.
// Grades are assigned on a 10 point spread.
// 90-100 A 80- 89 B 70-79 C 60-69 D Below 60 F
#include <iostream>
using namespace std;
const int MAXGRADE = 25; // maximum number of grades per student
const int MAXCHAR = 30; // maximum characters used in a name
typedef char StringType30[MAXCHAR + 1];// character array data type used for names
// having 30 characters or less.
typedef float GradeType[MAXGRADE]; // one dimensional integer array data type
float findGradeAvg(GradeType, int); // finds grade average by taking array of
// grades and number of grades as parameters
char findLetterGrade(float); // finds letter grade from average given
// to it as a parameter
int main()
{
StringType30 firstname, lastname; // two arrays of characters defined
int numOfGrades; // holds the number of grades
GradeType grades; // grades is defined as a one dimensional array
float average; // holds the average of a student's grade
char moreinput; // determines if there is more input
// Input the number of grades for each student
cout << "Please input the number of grades each student will receive." << endl
<< "This number must be a number between 1 and " << MAXGRADE << " inclusive" << endl;
cin >> numOfGrades;
while (numOfGrades > MAXGRADE || numOfGrades < 1)
{
cout << "Please input the number of grades for each student." << endl
<< "This number must be a number between 1 and " << MAXGRADE << " inclusive" << endl;
cin >> numOfGrades;
}
// Input names and grades for each student
cout << "Please input a y if you want to input more students"
<< " any other character will stop the input" << endl;
cin >> moreinput;
while ( moreinput == 'y' || moreinput == 'Y')
{
cout << "Please input the first name of the student" << endl;
cin >> firstname;
cout << endl << "Please input the last name of the student" << endl;
cin >> lastname;
for (int count = 0; count < numOfGrades; count++)
{
cout << endl << "Please input a grade" << endl;
cin >> grades;
// Fill in the input statement to place grade in the array
}
cout << firstname << ' ' << lastname << " has an average of ";
cout << findGradeAvg; // Fill in code to get and print average of student to screen
cout << findLetterGrade;// Fill in call to get and print letter grade of student to screen
cout << endl << endl << endl;
cout << "Please input a y if you want to input more students"
<< " any other character will stop the input" << endl;
cin >> moreinput;
}
return 0;
}
//***********************************************************************
// findGradeAvg
//
// task: This function finds the average of the
// numbers stored in an array.
//
// data in: an array of integer numbers
// data returned: the average of all numbers in the array
//
//***********************************************************************
float findGradeAvg(GradeType array, int numgrades)
{
float sum = 0;
for (int pos = 0; pos < numgrades; pos++)
{
sum = sum + array[pos];
}
return (sum / numgrades); // Fill in the code for this function
}
//***********************************************************************
// findLetterGrade
//
// task: This function finds the letter grade for the number
// passed to it by the calling function
//
// data in: a floating point number
// data returned: the grade (based on a 10 point spread) of the number
// passed to the function
//
//***********************************************************************
char findLetterGrade(float numgrade)
{
if (numgrade >= 90 && numgrade <= 100)
{
return 'A';
}
if (numgrade >= 80 && numgrade <= 89)
{
return 'B';
}
if (numgrade >= 70 && numgrade <= 79)// Fill in the code for this function
{
return 'C';
}
if (numgrade >= 60 && numgrade <= 69)
{
return 'D';
}
else
{
return 'F';
}
}
//此程序将输入不确定数量的学生姓名
//以及每个学生的分数。年级数为
//由用户提供。等级存储在一个数组中。
//为每个学生调用两个函数。
//一个函数将给出他们成绩的数值平均值。
//另一个函数将为该平均值提供字母等级。
//分数以10分的排列分配。
//90-100A 80-89B 70-79C 60-69D低于60华氏度
#包括
使用名称空间std;
常量int MAXGRADE=25;//每个学生的最大分数
常量int MAXCHAR=30;//名称中使用的最大字符数
typedef char StringType30[MAXCHAR+1];//用于名称的字符数组数据类型
//有30个字符或少于30个字符的。
typedef float GradeType[MAXGRADE];//一维整数数组数据类型
浮点findGradeAvg(GradeType,int);//通过获取的数组查找等级平均值
//作为参数的等级和等级数
字符findLetterGrade(float);//从给定的平均值中查找字母等级
//将其作为一个参数
int main()
{
StringType30 firstname,lastname;//定义了两个字符数组
int numOfGrades;//保存等级数
GradeType grades;//grades定义为一维数组
浮动平均值;//保存学生成绩的平均值
char moreinput;//确定是否有更多输入
//输入每个学生的分数
coutgrades
是一个数组
所以,使用
cin >> grades[count];
“C++中的数组可能有更多的问题,数组在很多方面都是特殊的。你的<代码> GradeType < /Cord> Type,掩盖了一个事实,即你有一个数组,从人类,如果不是编译器,这可能会使你的代码很难理解。谢谢。我现在还记得为什么它不起作用。我猜我是在想它。