I want to create a template as follows. I want to delete a list of items from vector vec1
. And the indexes of the items I want to delete are stored in ind
The compiler says
my_vector.h:21:2: error: need ‘typename’ before ‘std::vector::iterator’ because ‘std::vector’ is a dependent scope
So you need to write
typename vector< a_type >::iterator vec1_pre = vec1.begin();
typename vector< a_type >::iterator vec1_pos = vec1.begin();
See Where and why do I have to put the "template" and "typename" keywords? for the reasons behind it.
One last remark: In C++11 you can use auto
and don't have to think anymore:
auto vec1_pre = vec1.begin();
auto vec1_pos = vec1.begin();