Inheritance Problem in Perl OOP

Posted by Sam on Stack Overflow See other posts from Stack Overflow or by Sam
Published on 2010-04-08T16:10:00Z Indexed on 2010/04/08 16:13 UTC
Read the original article Hit count: 342

Filed under:
|
|
|

Hello,

I have a sub class that calls a method from a super class. and the method in the super class use a method that is defined in the super class as asbstract(not really abstract) but implemented in the sub class.

for example:

package BaseClass;

sub new {

} sub method1 {

return someAbstractMethod();

}

sub someAbtsractMethod { die "oops, this is an abstract method that should be implemented in a subclass" ; } 1;

package SubClass;

sub new {

}

sub someAbtsractMethod { print "now we implement the asbtract method"; } 1;

now when I do: $sub = new SubClass(); $sub->method1();

It calls the abstract message and i get the specified error message. if I took off the abstractmethod from the super class and just leave the implementation in the subclass, It does not recognize the method and I get subroutine abstractmethod not found error.

© Stack Overflow or respective owner

Related posts about oop

Related posts about perl