thcsoft has asked for the wisdom of the Perl Monks concerning the following question:
quite simple so far. imagine further that MotherClass provides all children with a common constructor, so that all children look somehow like:MotherClass / \ / \ / \ ChildClass1 ChildClass2
still simple. imagine still further, that in ChildClass1 some object methods are defined, which i like to use in ChildClass2 - but that there are signifant reasons speaking against inheriting Child2 from Child1, but from the Mother instead. So, my questions are:package MotherClass::ChildClass1; use strict; use vars qw/@ISA/; use MotherClass; @ISA = qw/MotherClass/; sub new { my ($class, $args) = @_; my $self = $class->SUPER::new($args); ... }
maybe i should mention, that Child1 does not export the method.package MotherClass::ChildClass2; use strict; use vars qw/@ISA/; use MotherClass; @ISA = qw/MotherClass/; use MotherClass::ChildClass1; ... sub object_method { MotherClass::ChildClass1::object_method(@_) }
|
---|