As you can see, the only major change is the addition of the _Initializable class to handle the creation of new objects, and the _init methods to initialize said objects. For any method other than a constructor, the options listed by lachoy above should work as advertised.#!/usr/bin/perl -w use strict; use Employee; my $hid = Employee->new; print "My gender is " . $hid->gender() . "\n"; print "My name is " . $hid->fullname() . "\n"; package Employee; use strict; use _Initializable; use Person; use Gender; @Employee::ISA = qw( _Initializable Person Gender ); sub _init { my $self = shift; $self->Person::_init(); $self->Gender::_init(); } 1; package Person; use strict; use _Initializable; @Person::ISA = qw( _Initializable ); sub _init { my $self = shift; $self->{FULLNAME} = "Robert Walkup"; } sub fullname { my $self = shift; return $self->{FULLNAME}; } 1; package Gender; use strict; use _Initializable; @Gender::ISA = qw( _Initializable ); sub _init { my $self = shift; $self->{GENDER} = "MALE"; } sub gender { my $self = shift; return $self->{GENDER}; } 1; package _Initializable; use strict; sub new { my $class = shift; my $self = {}; bless $self, ref($class) || $class; $self->_init(); return $self; } 1;
In reply to Re: Re: how do I do multiple inheritance
by Vavoom
in thread how do I do multiple inheritance
by rdww
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |