OK, I started the Manager pack with "our @ISA = "Worker" but I couldn't do any thing for Bob there, When I wrote "use base ("Worker")" I was able to initiate Bob but I could't activate the wc method. So Bob need to go out with the common people. Thanks guysmy $jhon = Worker->new_worker(); $jhon->print_worker_data(); my $telma = Worker->new_worker(name => "Telama", age => 25); $telma->print_worker_data(); my $bob = Manager->new_worker(name => "Bob", age => 40); $bob->print_worker_data(); $bob->wc(); ##===================================== package Worker; sub new_worker { ## Constructor. my $invocant = shift; my $class = ref($invocant); my $self = { name => "Jhon Do", age => 32, @_ , }; bless ($self) ; return $self ; }; sub print_worker_data { my $self = shift; print $self->{name} . " age is:". $self->{age}."\n"; }; ##=========================================== package Manager; use base ("Worker"); sub wc{ my $self = shift; print $self->{name} . " is in title to use the managers toilet\n"; + };
In reply to inheritance problems by michaelg
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |