in reply to OO Perl Inheritance - Is it possible somehow?
Although I generally agree with Bloodnok's suggestion of using composition where possible, this is actually a proper need for inheritance.
The problem you are having is due to the fact that the Kid should not be instantiated directly. If you think about it every male Kid should be a Kid::Son and every female Kid should be a Kid::Daughter. What does instantiating a generic Kid mean? In other languages, we could make this an abstract base class so that you can't create one, but can only create one of it's derived classes.
Looked at another way, you should never have a raw unsexed Kid lying around in your code. But, the Kid class defines an interface that is shared by both Kid::Son and Kid::Daughter.
The problem isn't with the OOP, it's that you are confusing the purpose of the base class. This kind of thinking is one of the hard parts of trying to learn OOP.
It does eventually make sense, BTW
|
|---|