Example:
Base class: Sentence
Derived classes: Sentence::Interrogative, Sentence::Declarative, Sentence::Imperative all use Sentence as a base class.
$s = Sentence->new("This is a test."); print ref($s); # Prints Sentence::Declarative $s = Sentence->new("Is this a test?"); print ref($s); # Prints Sentence::Interrogative $s = Sentence->new("Duck!"); print ref($s); # Prints Sentence::Imperative
In reply to Base class constructor that blesses into subclass by mp
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |