hi all,
maybe my qestion is dull, but since i'm not sure about the answer, i think i better let you blame me rather than doing it by myself...
imagine an inheritance tree like this one:
MotherClass
/ \
/ \
/ \
ChildClass1 ChildClass2
quite simple so far. imagine further that MotherClass provides all children with a common constructor, so that all children look somehow like:
package MotherClass::ChildClass1;
use strict;
use vars qw/@ISA/;
use MotherClass;
@ISA = qw/MotherClass/;
sub new {
my ($class, $args) = @_;
my $self = $class->SUPER::new($args);
...
}
still simple. imagine still further, that in ChildClass1 some object methods are defined, which i like to use in ChildClass2 - but that there are signifant reasons speaking against inheriting Child2 from Child1, but from the Mother instead. So, my questions are:
1.)am i right with the assumption, that inheriting ChildClass2 from both ChildClass1 and MotherClass may lead the compiler to complain about a "deep recursion"? (multiple inheritance would be the easy way of importing the methods from Child1.)
2.)since the methods i want to import into Child2's namespace are object methods, i have some doubts, whether the following construct would work:
package MotherClass::ChildClass2;
use strict;
use vars qw/@ISA/;
use MotherClass;
@ISA = qw/MotherClass/;
use MotherClass::ChildClass1;
...
sub object_method { MotherClass::ChildClass1::object_method(@_) }
maybe i should mention, that Child1 does not export the method.
i hope someone of you can shed some light on this (and me. :).
language is a virus from outer space.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.