M
maverik
Hi all.
I'm implementing class AbstractCollection - 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<typename T>
class AbstractCollection {
public:
AbstractCollection() : m_collection() {};
AbstractCollection(const AbstractCollection &collection);
AbstractCollection(const int n) : m_collection(n) {};
typedef std::vector<T>::iterator iterator; //
Try to define iterators for AbstractCollection
typedef std::vector<T>::const_iterator const_iterator;
private:
std::vector<T> m_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 AbstractCollection 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 AbstractCollection - 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<typename T>
class AbstractCollection {
public:
AbstractCollection() : m_collection() {};
AbstractCollection(const AbstractCollection &collection);
AbstractCollection(const int n) : m_collection(n) {};
typedef std::vector<T>::iterator iterator; //
Try to define iterators for AbstractCollection
typedef std::vector<T>::const_iterator const_iterator;
private:
std::vector<T> m_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 AbstractCollection 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.