First don't publicly inherit from std containers. They don't have virtual destructors.
you should use containment instead and add inline forwarding methods
i.e.
Code:
template <typename T>
class RAList
{
private:
typedef std::list<T> Container;
public:
typedef Container::iterator iterator;
// forward std::list methods
iterator begin(void) { return m_list.begin(); }
inline size_t size(void) const { return m_list.size(); }
private:
Container m_list;
};
the easiest way to implement the subscript operator is to use the std::advance algorithm.
also FYI the way to distinguish between pre and post increment operators is by adding an unused int parameter to the operator usually implemented like this
Code:
// pre-increment
MyClass& MyClass::operator++ ()
{
++m_number;
return *this;
}
// post-increment
MyClass MyClass::operator++ (int)
{
MyClass ans = *this;
++(*this);
return ans;
}
see the
C++ FAQ