C++ coding. Need the code(in c++) for the following functions of iterator where
ID: 3861355 • Letter: C
Question
C++ coding. Need the code(in c++) for the following functions of iterator where it says fill in here. code needs to be in C+++. Please help... public: /* class iterator { public: iterator(const persistent_vector pv, bool end=false): m_pv(pv), m_index(end?pv.m_size:0) {} // // This operator is used to get the value // that the iterator is currently pointing at // const T& operator *() { <FILL IN HERE> } // // This operator is used to move the iterator // to the next value in the container // iterator& operator ++() < <FILL IN HERE> } // // This operator is used to compare this // iterator to another one. It is mainly // used to determine when to stop iterating. // bool operator !=(const iterator& other) { <FILL IN HERE> } private: // // Store enough information to keep track of where you are // }; // // This returns an iterator pointing to the first element // of the persistent vector. // iterator begin() { return <FILL IN HERE> } // // This returns an iterator effectively pointing to the // element _after_ the last element in the persistent // vector. // iterator end() { return <FILL IN HERE> } */
Explanation / Answer
class iterator { public: iterator(const persistent_vector pv, bool end=false): m_pv(pv), m_index(end?pv.m_size:0) {} // // This operator is used to get the value // that the iterator is currently pointing at // const T& operator *() { return T* get()const; } // // This operator is used to move the iterator // to the next value in the container // iterator& operator ++()Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.