Hi all.
I'm implementing class AbstractCollect ion - just a wrap on std::vector
- to hide from clients the fact of using std::vector in the base
(because in the future I may change vector to a list or another DS).
So I try to do it in this way:
template<typena me T>
class AbstractCollect ion {
public:
AbstractCollect ion() : m_collection() {};
AbstractCollect ion(const AbstractCollect ion &collection) ;
AbstractCollect ion(const int n) : m_collection(n) {};
typedef std::vector<T>: :iterator iterator; //
Try to define iterators for AbstractCollect ion
typedef std::vector<T>: :const_iterator const_iterator;
private:
std::vector<Tm_ collection;
};
But the complier complains:
error C2146: syntax error : missing ';' before identifier 'iterator'
....
Can you tell me how to do it in the right way (how can I define
iterators for AbstractCollect ion using std::vector iterators)?
It would be nice if you also tell me what's wrong with my method (or
provide link to read about).
Thanks.
I'm implementing class AbstractCollect ion - just a wrap on std::vector
- to hide from clients the fact of using std::vector in the base
(because in the future I may change vector to a list or another DS).
So I try to do it in this way:
template<typena me T>
class AbstractCollect ion {
public:
AbstractCollect ion() : m_collection() {};
AbstractCollect ion(const AbstractCollect ion &collection) ;
AbstractCollect ion(const int n) : m_collection(n) {};
typedef std::vector<T>: :iterator iterator; //
Try to define iterators for AbstractCollect ion
typedef std::vector<T>: :const_iterator const_iterator;
private:
std::vector<Tm_ collection;
};
But the complier complains:
error C2146: syntax error : missing ';' before identifier 'iterator'
....
Can you tell me how to do it in the right way (how can I define
iterators for AbstractCollect ion using std::vector iterators)?
It would be nice if you also tell me what's wrong with my method (or
provide link to read about).
Thanks.
Comment