C++ STL: list with Pointers - Iterator cannot access?

Viewed 41126

I am struggeling with an STL list that holds Pointers of my "Object" object.

I declared:

list<Object*> objectlist;

and inserted via:

this->objectlist.push_back(new Object(address,value,profit));

and tried to iterate like in maps and others:

list<Object*>::iterator iter;

iter = this->objectlist.begin();

while(iter != this->objectlist.end())
{
    iter->print();
}

Where print() is a public Method of class Object;

Whats wrong here?

I cannot access via iterator to the objects in the list ?

7 Answers
Related