Hi guys,
I tried rewriting my C-ish C++ function to true C++, but I'm failing so far:
The first function (working)
const visualPart * entity::getVisualPart(unsigned int wantLOD){
for(unsigned int i = 0; i < visualEntity.size(); i++){
if(visualEntity[i]->LOD == wantLOD){
return visualEntity[i];
}
}
return NULL;
}
And the second (not working)
const visualPart * entity::getVisualPart(unsigned int wantLOD){
for(unsigned int i = 0; i < visualEntity.size(); i++){
if(*(visualEntity.begin() + i)->LOD == wantLOD){
return *(visualEntity.begin() + i);
}
}
return NULL;
}
The error I get from GCC's G++:
(...)entity.cpp|50|error: request for member `LOD' in `*(&(&(((std::vector<visualPart*, std::allocator<visualPart*> >*)((entity*)this)) + 44u)->std::vector<_Tp, _Alloc>::begin [with _Tp = visualPart*, _Alloc = std::allocator<visualPart*>]())->__gnu_cxx::__normal_iterator<_Iterator, _Container>::operator+ [with _Iterator = visualPart**, _Container = std::vector<visualPart*, std::allocator<visualPart*> >](((const ptrdiff_t&)((const ptrdiff_t*)(&((ptrdiff_t)i))))))->__gnu_cxx::__normal_iterator<_Iterator, _Container>::operator-|
Could you please point out what I'm doing wrong?
TIA,
Nick
PS:
I've learned that iterators are pointers to the elements, so in this case, the iterators are of type visualPart**, therefore I dereference them once to get access to LOD, but this doesn't seem to work. Why not?