I've defined my own class and stored objects of them in a std:list. Now I want to pick up all the elements, but something went wrong - I hope this is not too complicated to read:
std::map < long, FirstClass*> FirstClassMap;
std::map < long, FirstClass* >::iterator it;
it=this->FirstClassMap.begin()
//initialization of FirstClassMap is somewhere else and shouldn't matter.
list<SecondClass*>::iterator ListItem;
list<SecondClass*> depList = it->second->getSecondClassList();
for(ListItem = depList.begin(); ListItem != depList.end(); ++ListItem)
{
/* -- the error is in this Line -- */
FirstClass* theObject = ListItem->getTheListObject();
std::cout << theObject->Name();
}
Then there is the function:
SecondClass::getTheListObject()
{
return this->theObject; //returns a FirstClass object
}
FirstClass::Name()
{
return this->name //returns a string
}
Here I get the Error
Method 'getTheListObject' could not be resolved
and
Error:element request »getTheListObject« in »* ListItem.std::_List_iterator<_Tp>::operator->()«, whose pointer type is »SecondClass*« (maybe »->« was meant)
(I'm sorry, that I can't give you the correct error message. I have to translate it from German to English, I don't get these in English)
I don't really see the problem. Has anyone an idea?
Kind Regards