I'm trying to create a template function which receives a vector of some pointer to class T and clears the vector. However, with the below implementation I get compilcation errors. What am I doing wrong?
template <class T>
void clearVectorOfPointers(vector<T>& v){
for (vector<T>::iterator it = v.begin(); it != v.end(); ++it){
delete (*it);
}
v.clear();
}
symbolTable.cpp: In function ‘void clearVectorOfPointers(std::vector<T, std::allocator<_CharT> >&)’:
symbolTable.cpp:8: error: expected ‘;’ before ‘it’
symbolTable.cpp:8: error: ‘it’ was not declared in this scope