shemp has asked for the wisdom of the Perl Monks concerning the following question:
So i understand why child::_SetupData() isnt called from parent::new(), but im looking for a clean way to fix this problem, without taking the initialization out of the constructors, and into a setup method that must be explicitly called.package parent; sub new { my $class = shift; my ($setup_data) = @_; my $self = {}; bless $self, $class; $self->_SetupData($setup_data); return $self; } package child; use base qw(parent); sub new { my $class = shift; my ($setup_data) = @_; my $self = $class->SUPER::new($setup_data); return $self; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: class implementation question
by dws (Chancellor) on Jul 15, 2004 at 21:36 UTC | |
|
Re: class implementation question
by mojotoad (Monsignor) on Jul 15, 2004 at 21:30 UTC | |
|
Re: class implementation question
by shemp (Deacon) on Jul 15, 2004 at 22:07 UTC |