S
Steven Green
Hi Guys, I've been away from C++ since 2001 (been playing in Java land) but
I am trying to refresh my grey cells with C++.
What I am trying to do is wrap a std::list<T*> with a simple wrapper.
template <class T>
class Adapter
{
private:
std::list<T*> data;
public:
void remove(T*);
}
void Adapter<T>::remove(T *d)
{
std::list<T*>::iterator i = data.begin(); //the offencive line
}
Pardon me if there are any syntax errors in the above code, I am typing this
not cut and pasting.
The problem:
In th above code I create an iterator of type T*. This doesn't work it wants
the T* to be a class type:
For example:
std::list<Widget>::iterator i = data.begin(); //works
std::list<T*>::iterator i = data.begin(); //does not work.
I don't doubt that I am doing something dumb, but I cannot find my C++ book
(it is neatly tucked away under a pile somewhere to be sure)
Any thoughts on this would be appreciated.
Thanks,
Steve
I am trying to refresh my grey cells with C++.
What I am trying to do is wrap a std::list<T*> with a simple wrapper.
template <class T>
class Adapter
{
private:
std::list<T*> data;
public:
void remove(T*);
}
void Adapter<T>::remove(T *d)
{
std::list<T*>::iterator i = data.begin(); //the offencive line
}
Pardon me if there are any syntax errors in the above code, I am typing this
not cut and pasting.
The problem:
In th above code I create an iterator of type T*. This doesn't work it wants
the T* to be a class type:
For example:
std::list<Widget>::iterator i = data.begin(); //works
std::list<T*>::iterator i = data.begin(); //does not work.
I don't doubt that I am doing something dumb, but I cannot find my C++ book
(it is neatly tucked away under a pile somewhere to be sure)
Any thoughts on this would be appreciated.
Thanks,
Steve