This exercise is available at https://study.find-santa.eu/exercises/cpp/oop_inheritance/.
For the sake of the environment, please avoid printing these instructions in the future. Thank you!

OOP - Inheritance

Before submitting your solutions, make sure that cppcheck doesn't show any errors.

  1. Bank Account
    Extend your bank account example from the introduction to OOP exercise to contain additional account types. Do not touch the existing Account class. Instead, add new subclasses to cover the new requirements. Consider your original example open for extension but closed for modification. This is called the open–closed principle (OCP). This principle is one of the five SOLID principles of object-oriented design.
    Create the ChildAccount and TransferAccount classes in the same header as the Account class (account.hpp). The former must override (virtual!) the withdraw(.) function because children are not allowed to overdraw their accounts. The latter must implement an additional method that allows the transfer accounts to transfer money to other accounts.
    All classes must be implemented in separate header files. Also, each class must have a separate cpp file for implementing the new / changed methods. Your implementation must be done inside of a bank namespace. Use all three Account types in this mini-project's main.cpp file: Provide a Makefile that compiles the project.
    Follow the specification in the class diagram below:
    [Bank Accounts Class Diagram]
    The withdraw(.) method of the ChildAccount must allow withdrawals up to the current balance of the account. If someone tries to withdraw more money, issue a warning on stderr and only limit the amount paid out to the current balance. The actual amount withdrawn is returned to the caller.
    Reminder: the amounts are stored as integral numbers to avoid problems with floating point precision. The amount stored in the balance represents cents.
    Name the files account.hpp, account.cpp, child_account.cpp and transfer_account.cpp.