Friday, July 31, 2009

C++ question?

I am using C++ to write a program, 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';


}


}


34 minutes ago - 3 days left to answer.


Additional Details


17 minutes ago





It is still not working. I am getting the same error. Adding grade to char%26amp; did not work.

C++ question?
you've got grade defined as a function, but you are also using it as a variable. That's got the compiler confused
Reply:The first problem is you need to do


if(score %26gt; 70 %26amp;%26amp; score %26lt; 90)





The second problem is you need to do is change


grade = 'S';


Make a new char like gradeNEW or something.


Then do


gradeNEW = 'S';





when you use char grade the compiler is noticing it as the function grade aswell and gets confused. Hope this helps.
Reply:you can't do "if (70 %26lt; score %26lt; 90)"








you need to instead write "if (70 %26lt; score %26amp;%26amp; score %26lt; 90)"
Reply:try using


if(score%26lt;=70%26amp;%26amp;score%26lt;=90)


grade = 'S';


else if ( score =%26gt; 90)


grade = 'O';


else (score %26lt;= 70);


grade = 'U';


No comments:

Post a Comment