I have a template class that contains a container:
template <class T>
class MyClass
{
:
private:
std::list<T> ilist;
};
I have no problem accessing the STL container using subscript,
but I am unable to declare an iterator, as an example:
void MyClass<T>::erase(size_t n)
{
std::list<T>::iterator it;
...
g++ gives me an error:
containertest.cc: In member function ‘void MyClass<T>::erase(size_t)’:
containertest.cc:13: error: expected `;' before ‘it’
Note: I've included both <list> and <iterator>.
Now if I declare something like:
std::list<double>::iterator it;
or
std::liststd::string::iterator it;
Everything builds.
One possible solution is to inherit the list, but I wanted to avoid
inheriting STL containers.
--
Jerry Feldman