Next February 2001 Slide #41

Partial Inheritance

        Person->new($name, $age, $spouse);
        Employee->new($name, $age, $spouse, $boss, $department);
        package Employee;
        sub new {
          my $class = shift;
          my ($department, $boss);
          if (@_ == 5) { $department = pop @_ }
          if (@_ == 4) { $boss       = pop @_ }
          my $self = $class->SUPER::new(@_);
          $self->{BOSS} = $boss;
          $self->{DEPT} = $department;
          bless $self, $class;        
        }


Next Copyright © 2001 M-J. Dominus