Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re^2: has-a in Perl

by skazat (Chaplain)
on Apr 18, 2005 at 20:06 UTC ( [id://449001]=note: print w/replies, xml ) Need Help??


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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://449001]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (5)
As of 2024-04-19 07:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found