Given the following class:
template<class T>
class A {
vector<T> arr;
public:
A(int size);
A(vector<T> arr);
int size() const;
A& operator=(const A& p);
template<class S>
friend ostream& operator<<(ostream& os, const A<S>& p);
template<class S>
friend bool operator==(const A<S>& p1, const A<S>& p2);
};
How can I define iterator
and const_iterator
for my class? (I want to uses the iterators of the vectors instead to implement class iterator
and class const_iterator
)..
I want (for example) to support in something like that:
A a(5);
for(A<int>::iterator it = a.begin() ; it != a.end() ; it++) { /* .. */ }