The illustration shows a code segment with the lines numbered from 1 through 38 and the annotations are as follows:
"class SavingsAccount : public BankAccount" with the colon annotated as "The colon indicates that the class SavingsAccount is derived from the class BankAccount"
"{
public:
SavingsAccount(int dollars, int cents, double rate);
"//Other constructors would go here"
void deposit(int dollars, int cents);
//Adds $dollars.cents to the account balance
void withdraw(int dollars, int cents);" annotated as "Only new member functions or variables need to be defined."
"//Subtracts $dollars.cents from the account balance
private:
};
int main( )
{
SavingsAccount account(100, 50, 5.5);
account.output(cout);
cout << endl;
cout << "Depositing $10.25." << endl;
account.deposit(10,25);
account.output(cout);
cout << endl;
cout << "Withdrawing $11.80." << endl;
account.withdraw(11,80);
account.output(cout);
cout << endl;
return 0;
}"
"SavingsAccount::SavingsAccount(int dollars, int cents, double rate):" annotated as "The SavingsAccount constructor invokes the BankAccount constructor. Note the preceding colon."
"BankAccount(dollars, cents, rate)
{
//deliberately empty
}"
"void SavingsAccount::deposit(int dollars, int cents)
{
double balance = getBalance();
balance += dollars;
balance += (static_cast<double>(cents) / 100);
int newDollars = static_cast<int>(balance);
int newCents = static_cast<int>((balance - newDollars) * 100);"
There is another annotation "The deposit function adds the new amount to the balance and changes the member variables via the set function."