Lecture 15: Inheritance
Thursday 03/29, 2007
[Up]
[Previous Lecture]
[Next Lecture]
Assigned Reading:
Slides As Shown:
Topics Covered:
- Answered some questions about
Project 3.
- Continued discussion on class derivation and inheritance.
In particular, we discussed how C++ handles compatibility between
derived class objects and base class objects.
We derived a ColorCube class from the Cube class which in turn
was derived from the Box class (see
previous lecture).
Programs shown:
-
Simple use of ColorCube, showing order of construction, destruction,
and use of base class methods.
cctest.cpp,
cctest.txt.
-
Passing a derived object to a function with base class reference parameters.
cctest2.cpp,
cctest2.txt.
-
Passing a derived object to a function with base class value parameters.
cctest3.cpp,
cctest3.txt.
-
Same as cctest3.cpp, but bar3() is compiled separately.
ccsep4.cpp,
cctest4.cpp,
cctest4.txt.
-
Checking out how assignment works, or doesn't.
cctest5.cpp,
cctest5.txt.
-
Checking out pointers and dereferencing.
cctest6.cpp,
cctest6.txt.
-
C++ lets you do BAAAAD things with arrays of objects.
cctest7.cpp,
cctest7.txt.
-
Checking out function overloading and inheritance.
cctest8.cpp,
cctest8.txt.
- Looked briefly at a Unix Graphical User Interface (GUI)
tool kit called GTKmm. This
tool kit is set up so you create customized windows using class
derivation. The "real life"
inheritance hierarchy is rather complicated.
The programs shown won't compile unless
you have gtkmm and associated libraries installed. The programs
are here, but you are much better off
looking at the GTKmm
tutorial.