Perl-Sensitive Sunglasses | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
However, I have reason to keep the Base object inside {Parent}, as there are other constructors which will be invoked by other methods in Lite class. There's a better way to do that by making the constructor in the parent class subclass-friendly. This involves checking the first argument you get in an OO constructor routine and identifying if it has a valid ref() associated with it. If you write your constructors as my example code below shows, you'll be making life easy for anyone else who wants to built on your code base. In the code below, note a couple of things:
Here's the example code structure: File: consumer.pl
File: Ex/Parent.pm (the parent class)
File: Ex/Improved.pm (the subclass)
In reply to Re^3: Inheritance confused
by Apero
|
|