I'm having trouble doing multiple inheritance...I want to inherit not only
the subroutines from two classes, but also the instance variables. how do i
do this?
Methods are the easy part:
our @ISA = qw(ClassOne ClassTwo Etc);
Perl doesn't really provide a method for instance variable inheritance (even for single inheritance), but you can generally roll your own easy enough. Here's one possible method:
sub new { my $class = shift; my $object = { }; $object = $_->new(%$object) foreach @ISA; # class specific initialization here... return bless $object, ref($class) || $class; }
This is heavily dependent on the classes you are trying to inherit from though, so you may have to get a little more creative. Watch for parent classes stomping on each others' member data with this too, it could happen.
If you need something more robust, you might create instances of the parent classes as store them internally as private instance data. You could then basically use your class as a proxy for them, passing what is needed, to who, when. You probably need to do a little more subroutine work for this method, though I imagine most of them would just be one-liners calling the appropriate parent method on the internal object. A good AUTOLOAD with a little can() magic should even get you around this, if you're Lazy.
Well, hopefully that at least gives you a couple of ideas. Good luck.
James
-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]