C++ Class
#Class, Inheritance, polymorphism and STL
1. (15 points). Implement a class called BankAccount.
The class should have the following member variables:
account_number - int
balance – a double that holds the balance on the account
transcations – a vector of double includes all transactions, including deposit (a positive value), withdraw (a negative value) and monthly interest (a positive value).
The class should have 3 constructors (a default constructor, a copy constructor), accessors and mutators functions, a function to return the number of accounts, and deposit and withdraw functions.
a) UML diagram
b) implement the BankAccount.h file.
c) implement the BankAccount.cpp file.
2. (20 points) Consider a class SavingsAccount that is derived from the BankAccount class. The derived SavingsAccount class has an additional member, monthInterestRate, which holds the monthly interest rate for the account. The class has a constructor (calling the base class’s constructor) and a calcInterest function that returns the monthly interest on the account.
a) implement the SavingsAccount.h file
b) implement the SavingsAccount.cpp file
c) Write a main () function that:
· Declares a pointer of BankAccount to refer to an array of 5 SavingsAccount objects.
· Assigns values to the member variables using the mutator functions.
· Print the number of accounts that have been created (call the function you implemented above)
· Prints out the account number and balance of each element of the array using the accessor functions.
· Print the account with the maximal balance.
3. (15 points)
a) define a pure virtual function transfer in the BankAccount class (the question #1), can you still instantiate the BankAccount after adding the pure virtual function? Explain your answer?
void transfer (BankAccount &DestAcc, double transferAmount)
b) implement a transfer function in SavingAccount class to override the above virtual function,
The function should transfer transferAmount from the source account to destAcc.