I am using C++ to write a program for class, and I keep getting the following error: "error C2064: term does not evaluate to a function taking 2 arguments".
The error is in reference to this function call:
grade (gradeBook, grade);
and here is the prototype and the actual function:
void grade(studentInfo gradeBook [ ], char%26amp;);
void grade (studentInfo gradeBook [ ], char%26amp; grade)
{
int student;
int score;
for (student=0; student%26lt;=10-1;student++)
{
if (70 %26lt; score %26lt; 90)
grade = 'S';
else if ( score %26gt; 90)
grade = 'O';
else (score %26lt; 70);
grade = 'U';
}
}
C++ Error Message?
You have a function named 'grade' but inside your 'for' loop you have assignment statements such as 'grade = 'S';' which use 'grade' as a variable, but never declared a variable named 'grade' or told the compiler what data type the variable 'grade' is.
Also you cannot use the same identifier 'grade' for the name of a function and also as the name of a variable. So use a different name for the variable such as 'myGrade'. But before you assign any value to 'myGrade' you must declare that it is a variable of type char by writing the statement
char myGrade;
A third issue is in your conditional
if(70 %26lt; score %26lt; 90)
That is incorrect syntax. This conditional is proper:
if(70 %26lt; score %26amp;%26amp; score %26lt; 90)
But if you use 'myScore' as the variable name, then that would be
if(70 %26lt; myScore %26amp;%26amp; myScore %26lt; 90)
If you want to include values of 70 and 90, then you might want to use %26lt;= instead of %26lt;.
Reply:Your function signature is different to the function itself.
Change the first
void grade(studentInfo gradeBook [ ], char%26amp;);
to
void grade(studentInfo gradeBook [ ], char%26amp; grade);
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment