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.



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Al Heck

Unity Developer and Software Engineer who loves making games with GameDevHQ