... are obtained by calling each Account’s getName and getBalance member functions.

Fig. 3.9 Displaying and updating Account balances.

Alternate View

 1   // Fig. 3.9: AccountTest.cpp
 2   // Displaying and updating Account balances.
 3   #include <iostream>
 4   #include  "Account.h"
 5
 6   using namespace std;
 7
 8   int main()
 9   {
10      Account account1{"Jane Green", 50};
11      Account account2{"John Blue", -7}; 
12
13      // display initial balance of each object
14      cout << "account1: " << account1.getName() << " balance is $"
15         << account1.getBalance();
16      cout << "\naccount2: " << account2.getName() << " balance is $"
17         << account2.getBalance();
18
19      cout << "\n\nEnter ...

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.