I have this set of classes:
Node (SUPER Class)
|—— NodeType1 (Class)
|———-NodeType2 (Class)
There are fields that the type1 and type2 have in common (For example: NAME).
If i declare the NAME field in the SUPER class (Node) how should I access those variables in the types classes? How can i make those property’s?
Thank you for your time
If the access modifier of the
namefield ispublicorprotectedyou will be able to access it in your derived classes. The modifierpublicwill make it visible to all other classes, whileprotectedwill restrict visibility to the derived classes.In either case you can just access it as you would a field declared in the current class:
If you wish to make it a property then set it’s access modifier accordingly: