perl.org wrote: > I have a vendor-provided OO package and a custom OO package. The > custom package does not need a constructor. I want to have a class > that inherits from both. It also does not need a constructor - it > should use the constructor from the vendor-provided package. > > I have a problem when my inheriting class tries to call methods my > custom superclass - it says the method is not available to the > subclass (Can't locate object method "whatever" via package). Does > this mean all of the classes need to have constructors?
If the base class constructor is written properly, it should be inheritable. If not, you'll have to write one. Inheritable: sub new { my $class = shift; bless {}, $class; } Not inheritable: sub new { bless {}; } also not inheritable: sub new { bless {}, 'My::Class'; } > If so, in my > constructor, how do I explicitly call the parent constructor? package Bar; @ISA = qw/Foo/; sub new { my $class = shift; bless Foo->new(@_), $class; } > And in > the case of multiple inheritence, will it automatically call all > constructors in the ISA array? No. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>