3.3 Account
Class with a Data Member and Set and Get Member Functions
Now that we’ve seen class Account
in action (Fig. 3.1), we present class Account
’s details. Then, we present a UML diagram that summarizes class Account
’s attributes and operations in a concise graphical representation.
3.3.1 Account
Class Definition
Class Account
(Fig. 3.2) contains a name
data member that stores the account holder’s name. A class’s data members maintain data for each object of the class. Later in the chapter, we’ll add a balance
data member to keep track of the money in each Account
. Class Account
also contains member function setName
that a program can call to store a name in an Account
object, and member function getName
that a program can call to obtain ...
Get C++ How to Program, 10/e now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.