I have 5 or 6 classes that I want to have follow the same basic structure internally. Really most of those that the classes should follow are just for the use of the function itself, so I really want these methods to be private.
Is there any way to achieve this? I know interfaces would work great but they won’t take private members and won’t allow you to redefine the scope in the implemented method. Is there any workaround for this?
Thanks
I think the closest you can get is using an
abstractclass withabstractprotectedmethods:To define common logic, you can call the protected method from a private method in the super class:
This way, you can allow subclasses to fill the private common template method with specific behavior.