Notes
Slide Show
Outline
1
CS 211:
Introduction to Computer Programming II
  • Instructor: Brian M. Dennis
  • Teaching Assistants:
  • Tom Lechner, Bin Lin, Rachel Goldsborough
  • http://www.cs.northwestern.edu/~bmd/cs211/


2
Inheritance
3
Inheritance
4
Inheritance
5
Inheritance
  • // Just for completeness' sake


  • void Car::display() {
  • cout << producer << "["
  • << vin << "]" << endl;
  • }
6
Inheritance
7
Inheritance
8
Inheritance
9
Inheritance
10
Inheritance
11
An Inheritance Example
12
Builtin string class
  • char* strings are lame
    • Can't hold null characters
    • Can be conflated with a pointer to a single char
    • Can't directly compare
    • Small library of operations
    • No bounds checking


  • string class fixes many of the problems


13
That’s a Wrap
  • Takeaway
  • Inheritance promotes reuse
    • Interface
    • Data structuring
    • Implementation code
  • Reading
    • 9.1 – 9.5