Passing by reference?

Any advice would be greatly appreciated. In this program when a student receives a low score or high score, a message needs to be printed. However, I cannot seem to make the program run.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
//Prototype
void Comments(Student_Data & student);


//Structures

struct Exam_Score
{
double exam[5];
string comment; // Will print good job or need to study more.
};

struct Student_Data
{
string name;
int age;
Exam_Scores exams[3];
};


int main()
{
for (int i=0; i < 3; i++){
   for (int j=0; j < 3; j++){
      for (int k=0; i < 6; k++){

        string Comment = Comments(student[i].exams[j].exam[5]); //This is avg.
        if (Comment.length() > 0)
        cout << Comment << endl;
      }
   }
}



return 0;
}


1
2
3
4
5
6
7
8
9
10
11
12
void Comments(Student_Data & student)
{
for(int i=0; i < STUDENTS; i++){
    for (int j=0; j < EXAM_DATA; j++){
          if (student[i].exams[j].exam[5] < 70.00)
               return FAILURENOTICE;
        else if (student[i].exams[j].exam[5] >= 95.00)
               return SUCCESSNOTICE;
        return "";
}
}
}
void functions do not have return values, therefore;
string Comment = Comments(student[i].exams[j].exam[5]);
is invalid.
I also get error when I change it to
1
2
3
4
5
6
7
8
9
10
11
12
13
string Comments(Student_Data & student)
{
for(int i=0; i < STUDENTS; i++){
    for (int j=0; j < EXAM_DATA; j++){
          if (student[i].exams[j].exam[5] < 70.00)
               return FAILURENOTICE;
        else if (student[i].exams[j].exam[5] >= 95.00)
               return SUCCESSNOTICE;
        return "";
}
}
}



Also, I tried to maybe change my argument/parameter to this:
 
string Comments(student[].exams[].exam[])


I really do not understand how to pass this nested structure by reference...
If someone could shed some knowledge on this, responses are welcomed
Topic archived. No new replies allowed.