in reply to really simple OO inheritance question
You're calling the method before all the class initialization is complete. Normally I'd put all the class definitions before any "executable code". It turns out, only one statement in your code above is not getting executed in time for your Cow->speak call, and that's the
statement. That is (unfortunately) "normal" code, not definitional. You can make it happen earlier by putting it in a begin block:our @ISA = qw(Animal);
but it's considered better practice (by some, anyway) to use a real pragmatic statement to define your inheritance relations:BEGIN { our @ISA = qw(Animal); }
use base 'Animal';
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: really simple OO inheritance question
by tomgracey (Scribe) on Jun 27, 2010 at 13:19 UTC |