Before submitting your solutions, make sure that cppcheck doesn't show any errors.
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.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.
Account
types in this mini-project's main.cpp file:
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.
account.hpp
, account.cpp
,
child_account.cpp
and transfer_account.cpp
.