Class Data Fields

A common need is to have all instances of a class share a common data field. It's a simple idea in principle, but comes with a subtle paradox. Classes are used to define common behavior. That means every instance of a class shares the same behavior with every other instance. having noted this, we can then ask who is responsible for initializing the common data field. Seemingly either everybody must do this, which seems bad, or nobody will, which is also bad.

This paradox is resolved in different ways in the various different object-oriented langauges. See the book for details.

[audio] [real] Text to accompany slide32, in Chapter 4 of An Introduction to Object-Oriented Programming