in reply to Point me in the right direction with OO inheritance and static variables
hi Amblikai,
If what choroba and tobyink gave are too strong a drink to take all at once, you can check this soft milk
use warnings; use strict; package Animal; sub new { my $class = shift; my $self = { 'name' => shift || 'Ologbo', 'tail' => shift || 'Yes', }; return bless $self, $class; } package Cat; use base 'Animal'; sub nameMe { my $self = shift; return $self->{'name'}; } package main; my $cat = Animal->new; print $cat->{'name'}, $/; # Ologbo my $cat2 = Cat->new('Blackky'); print $cat2->nameMe # Blackky
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Point me in the right direction with OO inheritance and static variables
by McA (Priest) on Sep 02, 2014 at 14:38 UTC | |
|
Re^2: Point me in the right direction with OO inheritance and static variables
by Amblikai (Scribe) on Sep 02, 2014 at 11:44 UTC |