Hi there,
I know what inheritance is, I just don't really know when to apply it and how to use it properly, but I am pretty sure I should be using it for my current project, I just don't know how to go about doing it.
In Sudo code here is what my main class does (it does more stuff - but heres the important bit):
Class A and Class B have the same public variables/events/methods, but have different logic for how they are raised/what they do and have different private variables/methods
Is there something I can do so that when either Class A or Class B are created (only one is used at one time), they are assigned to a variable/reference and i can use that variable to call the methods regardless of which class is referenced, because at the moment, for ever method i have in my main class, I have to do an if statement to check which class is created.
Hope this makes sense.
Thanks.
I know what inheritance is, I just don't really know when to apply it and how to use it properly, but I am pretty sure I should be using it for my current project, I just don't know how to go about doing it.
In Sudo code here is what my main class does (it does more stuff - but heres the important bit):
Code:
On Class Load -> Create [Class A] or [Class B]
Class A and Class B have the same public variables/events/methods, but have different logic for how they are raised/what they do and have different private variables/methods
Is there something I can do so that when either Class A or Class B are created (only one is used at one time), they are assigned to a variable/reference and i can use that variable to call the methods regardless of which class is referenced, because at the moment, for ever method i have in my main class, I have to do an if statement to check which class is created.
Hope this makes sense.
Thanks.
Last edited: