Need help with arrays that returns ith element

Just need help understanding what this do students[i]. Like I'm really confused with the [i] part I understand arrays but just not that. I'm assuming that it sores a value in the function it calls what I'm guessing.

Btw I'm reading accelerated c++ im between chapter 5-6 im sure I know what it does just wanna be postively sure.
Just for clarification, the declaration of students is this (taken from the book):

vector<Student_info> students;

This means students is a vector. That means it can hold many Student_info objects.

When I say students[0], I am getting the first Student_info object from that vector.

i in that example is used as an index that gets incremented in a loop. So the first time in the loop, you access students[0]. The second time, students[1], etc.

So each time through the loop, you are taking the i'th element of that array, and you are outputting the return value of the name function for the student object.

Hope that helps!
Topic archived. No new replies allowed.