in reply to Objects and Inheritance
If you have an class, Foo::Bar, that inherits from Foo, and you call:
my $obj = Foo::Bar->new;
It doesn't matter if the constructor is in Foo or Foo::Bar, if you're using the two argument form of bless. Your referent will still be tagged with Foo::Bar. You want this behavior, or else inheritance would break. If you want a Foo object, instantiate one.
If you're trying to figure out if Foo::Bar is a Foo, try this:
if ( $obj->isa( 'Foo' ) ) {...}
Cheers,
Ovid
Join the Perlmonks Setiathome Group or just click on the the link and check out our stats.
|
|---|