Reputation: 29
I am having a error from the compiler telling me that "student" "does not refer to a value" it was to my understanding student.test refers to a value and that value has already be initialized to the variable. I need help
int main() {
ifstream dataIn;
ofstream dataOut;
struct student{
string lastName=" ";
string firstName=" ";
int test1=0;
int test2=0;
int test3=0;
int test4=0;
int test5=0;
};
char grade=' ';
int total=0;
int average =0;
average=averageScore(student.test1, student.test2, student.test3, student.test4,student.test5,student.average, student.total);
Upvotes: 0
Views: 53
Reputation: 9376
The problem is that struct student
is a type definition and not a variable declaration.
Therefore, in order to access the fields you should declare a variable of this type, and use the variable and not the class i.e.:
student st;
char grade=' ';
int total=0;
int average =0;
average=averageScore(st.test1, st.test2, st.test3, st.test4,st.test5,st.average, st.total);
(And also, as Mr. Yellow mentioned the average field is not defined for struct student
)
Upvotes: 2