mardi 3 juillet 2018

How can I define iterator and const_iterator in my class while I uses std::vector as field in my class?

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)..

Aucun commentaire:

Enregistrer un commentaire