in reply to how to create instances of classes ....
Calling Child->new will call Parent's new() method, but $class will be 'Child', not 'Parent'.package Parent; sub new { my ($class, @args) = @_; bless [ @args ], $class; } package Child; @ISA = 'Parent';
The "trick" is using the first argument to the class method as the class name, not hardcoding the class name into your code.
|
|---|