Inheritance in Java Netbeans 7.0.1
I am using Net Beans 7.0.1 and i have made a parent class and 7 child classes. How can I restrict some child clause to call some functions of the parent class but allow other child clauses to call those functions?
I am using Net Beans 7.0.1 and i have made a parent class and 7 child classes. How can I restrict some child clause to call some functions of the parent class but allow other child clauses to call those functions?
Are you using java programming language? As far as I have learned, there are three access modifiers the Public, Private and the Protected. As in your case I suggest that you use the protected access modifier. With Protected access, only the subclass of a parent class can access its members / methods. For example, we have Class A which is a parent class of subclasses Aa and Ab. In addition, Aa1 is a sub-subclass of subclass Aa. If Aa has a protected member or method, they are accessible only by Aa1 and NOT by Ab. So for functions that you want for some classes to access, you make it protected to a subclass and not in the parent class so that only those that can access the protected method can derive it from the subclass and those that can't will derive from the parent class.