Lab

Step 1

Add a virtual function to the BankAccount class called AccrueInterest(). The purpose of the function will be to increase the balance by 2%. Call AccrueInterest() on an instance of BankAccount, CheckingAccount, and SavingsAccount and write the balances of each to the console.

Make the AccrueInterest() function in BankAccount abstract. Try compiling the code. Since there is no such thing as a regular bank account (ie. they are typically checking, savings, etc) make the BankAccount class abstract and fix any compiler errors by removing any calls to create a new instance of BankAccount. Make sure to override the function in the derived classes.

You must sign up to see the rest of this content.