tolord

Untitled

Dec 11th, 2017
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.65 KB | None | 0 0
  1.     class list_iterator {
  2.         element* data;
  3.     public:
  4.         list_iterator(element* _data) : data(_data) {}
  5.         list_iterator& operator++ (){
  6.             if (data == nullptr) {
  7.                 throw new exception();
  8.             }
  9.             element* temp = data;
  10.             data = data->next;
  11.             return list_iterator(temp);
  12.         }
  13.         int operator* () {
  14.             return data->data;
  15.         }
  16.         friend bool operator== (const list_iterator left, const list_iterator right) {}
  17.     };
  18.  
  19. ...
  20.  
  21. list_iterator begin () {
  22.     return list_iterator(head);
  23. }
  24. list_iterator end () {
  25.     return list_iterator(nullptr);
  26. }
Advertisement
Add Comment
Please, Sign In to add comment