im using g++ on ubuntu 10.10
i have a pointer to a vector of pointers to objects and i want to call a method on each of those objects.
oc->features is defined as:
vector<Feature* >* features;
i have to do:
this works, but if i try to use the itterator directly, as in:
I get the following compile error:
ViewEvaluator.c pp:48: error: request for member ‘scoreFeat ure’ in ‘* it.__gnu_cxx::_ _normal_iterato r<_Iterator, _Container>::op erator-> [with _Iterator = Feature**, _Container = std::vector<Fea ture*, std::allocator< Feature*> >]()’, which is of non-class type ‘Feature*’
//make[2]: *** [CMakeFiles/testOVAS.dir/ViewEvaluator.c pp.o] Error 1
//make[1]: *** [CMakeFiles/testOVAS.dir/all] Error 2
non-class type Feature* ?? i dont get it...
can anyone shed light on what might be happening here?
incidentally i thought it could be something to do with having a pointer to a container and using an itterator on it (at first i tried dereferencing that didnt work). I then realised that i have another example in my code using a pointer to vector and the analogous code works.
i have a pointer to a vector of pointers to objects and i want to call a method on each of those objects.
oc->features is defined as:
vector<Feature* >* features;
i have to do:
Code:
vector<Feature*>::iterator it; for (it=oc->features->begin();it!=oc->features->end();it++){ Feature* a=*(it); int score=a->scoreFeature(view); }
Code:
int score=*(it)->scoreFeature(view);
ViewEvaluator.c pp:48: error: request for member ‘scoreFeat ure’ in ‘* it.__gnu_cxx::_ _normal_iterato r<_Iterator, _Container>::op erator-> [with _Iterator = Feature**, _Container = std::vector<Fea ture*, std::allocator< Feature*> >]()’, which is of non-class type ‘Feature*’
//make[2]: *** [CMakeFiles/testOVAS.dir/ViewEvaluator.c pp.o] Error 1
//make[1]: *** [CMakeFiles/testOVAS.dir/all] Error 2
non-class type Feature* ?? i dont get it...
can anyone shed light on what might be happening here?
incidentally i thought it could be something to do with having a pointer to a container and using an itterator on it (at first i tried dereferencing that didnt work). I then realised that i have another example in my code using a pointer to vector and the analogous code works.
Comment