Introduction to OOP: Chapter 15 : Case Study: Container Classes [next] [previous] [audio] [real] [text]

List and Link

class List {
public:
	... // same as before

	void Add(void * v)
		{ firstElement = new Link(v, firstElement); }
	
	void * First()
		{ return firstElement->value; }

	... // same as before
};

class Link {
		// constructors
	Link (void * v) : next(0), value(v) {}
	Link (void * v, Link * n) : next(n), value(v) {}

		// data areas
	Link * next;
	void * value;
};
Intro OOP, Chapter 15, Slide 12