I definitely do not see the big picture here.

If I am not able to reach the child's getSex() sub in a simply way, then whats the point of the inheritance. I mean the Parent should know about the child's subs.

If I do the inheritance coming from the other direction, so the Son+Daugther are the parents and the Kid is the child then I will be able to reach the subs, but this is logically wrong.

Kid.pm ------ package Kid; @ISA = (Son); use Son; sub new { } Son.pm ------- package Son; sub new { } sub getSonSex { print("I'm a boy \n"); } test.pl ------- use Kid; use Son; $kid = Kid->new(); # It's OK $kid->getSonSex();
I'm getting more and more confused about these OO terms :)


In reply to Re^2: OO Perl Inheritance - Is it possible somehow? by kEndE
in thread OO Perl Inheritance - Is it possible somehow? by kEndE

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.