Bank System Inheritance Example with Protected Members

Let’s create a banking system. First, let’s define the bank with the proper variables that all banks share.

We want to do 3 functions — check balance, withdrawl, and deposits. Next, let’s create a bank and define it’s role.

Let’s create a new class- a credit union — that inherits from the bank class.

You can also set your public variables to be protected — that way only subclasses that inherit can access the information.

We can also protect the functions as well.