C++ iterator for custom template class -
i have nested iterator in custom stack template class. problem nested iterator's constructor not match when create iterator stack in main. wonder problem be.
template <class t> class stack { private: int top; t st[100]; public: class my_iterator { public: my_iterator() : list(0), curr(0) {}; private: stack<t> list; int curr; }; //publics in stack class public: stack(); void push(t i); t pop(); void print(); bool is_full(); my_iterator begin() {}; };
and create iterator stack following line in main
stack<double>::my_iterator it;
it looks forgot *
:
class my_iterator { public: my_iterator() : list(0), curr(0) {}; private: stack<t>* pstack; // pointer stack. int curr; };
of course, need more members (including better constructors) class. should @ least allow create default iterators not point stack in particular.
Comments
Post a Comment