## 20.6 Private Inheritance - example (cont.)

- `Set` method may call `push_back`
- `push_back` is not part of `Set`'s interface:

  > `Set a_set;
  > a_set.add("Sally"); // legal
  > a_set.push_back("Fred");
  > // Error--push_back not part of interface for Set`

- Private inheritance is rarely used
- `Set` could've instead had a private `List` attribute (aggregation)
- Similarly, protected inheritance exists, but is used even less often

prev |top |next