C++ Lecture 8 - C+ Lecture 8

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
C++ Lecture 8 http://www.cs.mun.ca/~gstarkes/3710/c++/lecture8.html 1 of 4 4/13/2009 5:29 PM C++ Lecture 8 [Previous Lecture] [Lecture Index] L.h #ifndef LIST_H # define LIST_H class List { struct ListLink { ListLink( int v) : val(v), next(0) { } int val; ListLink *next; }; public: typedef struct ListLink *Iterator; List(); List(const List &ic); ~List(); Iterator getIterator() const; bool getNext(Iterator &iter, int const; void add( int val); bool remove(const int &val); void removeAll(); private: ListLink *head; ListLink *tail; }; #endif /* LIST_H */ L.cc // . .. bool List::getNext(Iterator &iter, int if (!iter) return false; val = iter->val; iter = iter->next; return true; } void List::add( int val) { ListLink *n = new ListLink(val); if (tail) tail->next = n; else head = tail = n; tail = n; }
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
C++ Lecture 8 http://www.cs.mun.ca/~gstarkes/3710/c++/lecture8.html 2 of 4 4/13/2009 5:29 PM Lt.h #ifndef LIST_H # define LIST_H template <class T> class List { struct ListLink {
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 12/24/2009 for the course PROGRAMMIN C++ Progra taught by Professor Showman during the Spring '09 term at Zagazig University.

Page1 / 5

C++ Lecture 8 - C+ Lecture 8

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online