I'm trying to iterate over a vector holding a pointer to an object of type Student.
The declaration of vector is as follow: static vector<Student*> students;
Anyhow, I am trying to use an iterator in function pickWinners():
vector<Student*>::iterator p1 = students.begin();
vector<Student*>::iterator p2 = p1;
p2++;
As I understand, p1 is a pointer to a pointer to Student. But when I try this (for example):
*p1->print();
I get the next error:
Hire.cpp:192: error: request for member ‘print’ in ‘* p1.__gnu_cxx::__normal_iterator<_Iterator, _Container>::operator-> with _Iterator = Student**, _Container = std::vector >’, which is of non-class type ‘Student*’ make: * [Hire.o] Error 1
This doesn't make any sense to me. I know the problem is not in print(). I tried
Student *student = students.at(0);
student->print();
and everything worked perfect. I'm pretty clueless here, any ideas? Thanks!