Inheritance
The bless function gives more information to a reference. It makes the reference be of a type: Student in this case. This has several uses in Perl, as we shall see. Using public methods to access private data is not the only benefit of the object-oriented approach. Another important principle, inheritance, is the cornerstone of object orientation.
Inheritance is one of the principal ways of implementing code reuse. The following are examples of inheritance relationships.
A Directory is a type of File.
A Manager is a type of Employee.
A Car is a type of MovingVehicle.
A Circle is a type of Shape.
Sometimes inheritance is characterized as the is-a relationship. In the File–Directory relationship, we say that a Directory is-a File. Likewise, ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access