If I understand it right, in C++, which is where I first learned OOP, instantiating a child object always instantiates a complete object of the base class as well. All of the base class data members and methods are availabe, even if they are overidden by the child.

The problem that I started with is one that I've never had in C++ (or python as far as I recall). That doesn't mean that perl is "bad" or anything. Just different. I see that there is a different approach to OO in perl than C++. Nothing wrong with different, per se.

I like all the interesting ideas presented in these solutions. But I didn't use any of them. Most of them require the parent to have some knowledge of the children that may inherit from it. Which is a big OO no-no in my opinion.

What I ended up doing was replicating some of the parent method's functionality in the child method. This is something that I shouldn't have to do. That's part of the point of inheritance to re-use that code. But I find that with perl, its easier to do that than to go through shenannigans to access parent methods of a parent object that is never actually instantiated...

Thanks for your many replies. it has been a learning experience, and I will continue to follow the thread and I will return to perl-monks now that I have found such a great community!


In reply to Re^3: my $self is stumped! by headybrew
in thread my $self is stumped! by headybrew

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.