Introduction to OOP Chapter 14: Polymorphism and Software Reuse: next previous audio real text

Using Inheritance

Only need specify what is new - the addition method. Everything else is given for free.

class Set : public List { 
public: 
	void add(int);
};

void Set::add(int x) 
{
	if (! includes(x)) // only include if not already there
		List::add(x);
}
Intro OOP, Chapter 14, Slide 06