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

Hiding the Links

We can avoid the explicit manipulation of links by subclassing the List class, as well as the Link class.

class DoubleList : public List {
	void Add(double v)
		{ List::add(new DoubleLink(v)); }

	double First()
		{ return firstElement->value; }

	int Includes(double v)
		{ DoubleLink v1(v);
		  return List::includes(v1); }
Intro OOP, Chapter 15, Slide 10