perl---inheritance of one class

来源:互联网 发布:时速4000超级列车 知乎 编辑:程序博客网 时间:2024/05/21 22:38
 Inheritance of one class by another requires no speacial syntax to be added to the language。 when you invoke a method for which Perl finds no subroutine in the invocant's package, that package's @ISA array  is examined. This is how perl implements inheritance: each element of a given package's @ISA array holds the name of another package, which is searched when methods are missing. For example, the following makes the Horse class a subclass of the Critter class.

  package Horse;

  our @ISA = " Critter" ;

  or

  our @ISA= qw(Critter);

原创粉丝点击