On Jan 5, 2004, at 12:44 PM, Shawn McKinley wrote:
Hello all, I am wondering if you can have object inherited between packages when the child packages have their own object creation without explicitly setting the parent object in the child? Is there a way to inherit the parent object? Example below (sorry for the length).
[..] Shawn,
Thank you for the illustrative code it was interesting but it also presented a part of the problem you might want to go back and re-think - in your illustration you have established a requirement for A::B inside of A - which is a fast track to having your object model turn into a Jeff Foxworthy Skit real fast.
you can simplify your basic new() down to simply sub new { my $class = shift; my $self = {}; bless $self, $class; } # end of our simple new note: <http://www.perlmonks.org/index.pl?node_id=52089>
since your B.pm
package A::B; A::B::ISA=qw(A); use strict;
it will be able to find the 'new' in the parent class and hence
my $b = new A::B;
will know that it is a blessed reference to the class "A::B" vice mutating itself into an A.
At about that point your code gets a bit WAKKA-WAKKA as to why you want to be defining/redefining methods based upon an object inclusion foo
I mean what would
$b->set_A("joe bob briggs");
mean to begin with, and worse yet what happens with
$b->func();
mean since last I heard Joe Bob was reviewing movies and not an Object of A...
have you peeked at the
perldoc perltoot
to begin with???
ciao drieux
---
-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>