Hi,
i'm coding on an exercise for class, and can't find an solution.
I've got a class Person
1 2 3 4 5 6
class Person{
private:
std::string name;
int alter;
float groesse;
std::string geschlecht;
and a class wich stores pointers to those Objects in a vector.
1 2 3
class PersonenListe{
private:
std::vector<Person*> p;
Now I set an iterator onto the first element of the vector p. And I want to access the string "geschlecht" via the iterator.
1 2 3 4 5 6
std::vector<Person*>::iterator it = p.begin();
if(it->geschlecht == 'M'){
counter++;
it++;
}
But I can't get it to work. I don't even understand the error i get.
Error:
"PersonenListe.cpp:35:16: error: request for member 'geschlecht' in '* it.__gnu_cxx::__normal_iterator<_Iterator, _Container>::operator-><Person**, std::vector<Person*> >()', which is of pointer type 'Person*' (maybe you meant to use '->' ?)"