Perl: Multiple and multilevel inheritance

Perl: Multiple and multilevel inheritance

Multiple and multilevel inheritance in Perl

Multilevel inheritance means, a child package has one parent package which itself is a child package of another parent package.

Multiple inheritance means, a child package has two or more parent packages.

In the diagram above, it can be seen that, package ‘Manager’ is a child of package ‘Employee’ which is a child package of ‘person’. This is called multilevel inheritance.

Package ‘Manager’ is a child package of 2 parent packages ‘Person’ and ‘Human’. This is called multiple inheritance.

With the use of inheritance, child package can have all the properties of parent package, which avoids writing the same code again and again.

Advertisements

Tags: , , ,

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s


%d bloggers like this: