Reputation: 1
suppose there is a parent class and 3 child classes.If there's a method which needs to be included in two of the child classes where to place it?
Upvotes: 0
Views: 115
Reputation: 24626
I say the structure has to be like this
Parent
| |
Child ChildTwo
| |
ChildTwoFirst ChildTwoSecond
Here ChildTwo class will have your added method. Hope that might help
Regards
Upvotes: 2
Reputation: 239342
In the child classes which need it, either directly or by defining an intermediate super class for the two specific children which inherits from the parent. If the method cannot be invoked on the parent, or on all of its children, it doesn't belong in the parent.
Upvotes: 1