The C++Course provides a general introduction to programming in C++. It is based on A.B. Downey's book, How to Think Like a Computer Scientist. Click here for details.


Object-Oriented Design

Inheritance is a powerful feature. Some programs that would be complicated without inheritance can be written concisely and simply with it. Also, inheritance can facilitate code reuse, since you can customize the behavior of build-in classes without having to modify them.

On the other hand, inheritance can make programs difficult to read, since it is sometimes not clear, when a function is invoked, where to find the definition. For example, in a GUI environment you could call the Redraw function on a Scrollbar object, yet that particular function was defined in WindowObject, the parent of the parent of the parent of the parent of Scrollbar.

Also, many of the things that can be done using inheritance can be done almost as elegantly (or more so) without it.


Last Update: 2005-11-21