in reply to Re: has-a in Perl
in thread has-a in Perl

I'm basically just trying to make a method of my base class in a separate module (file) - but the method needs methods of the base class to work correctly.

It would be cool to be able to call this new method in my program via the base class or the separate module; So if I want to work with just Checkboxes, I got it, if I want to work with all my widgets, got that too - not a good idea?

 

-justin simoni
skazat me

Replies are listed 'Best First'.
Re^3: has-a in Perl
by Joost (Canon) on Apr 19, 2005 at 11:04 UTC
    It would be cool to be able to call this new method in my program via the base class

    That's what subclassing does: you can call any method from the base-class, and if the subclass implements or overrides that method, the subclass's method will be called.

    package Base; sub method1 { my $self = shift; $self->method2(); } sub method2 { print "Base\n"; } package Sub; @ISA = qw(Base); sub method2 { print "Sub\n"; } package main; Base->method1; Sub->method1; __END__ Base Sub