Section 1.8 presented a friendly introduction to object orientation, discussing classes, objects, data members (attributes) and member functions (behaviors).2 In this chapter’s examples, we make those concepts real by building a simple bank-account class. The class maintains as data members the attributes name
and balance
, and provides member functions for behaviors including
querying the balance (getBalance
),
making a deposit that increases the balance (deposit
) and
making a withdrawal that decreases the balance (withdraw
).
We’ll build the getBalance
and deposit
member functions into the chapter’s examples. You’ll add the withdraw
member function in Exercise 3.9.
As you’ll see, each class you create becomes a new type you can use to create objects, so C++ is an extensible programming language. If you become part of a development team in industry, you might work on applications that contain hundreds, or even thousands, of custom classes.