KKGanguly
KKGanguly

Reputation: 343

Object Hierarchy in OOP

What is Object Hierarchy actually,I cant differentiate it with Class Hierarchy.Are they actually the same thing?I have looked into answers on stackoverflow and googled it,but haven't found any clear explanations yet :(

Upvotes: 0

Views: 2974

Answers (1)

Aleks
Aleks

Reputation: 5864

There are not the same thing, they are in fact very different things. Confusingly enough, class hierarchy is informally often called object hierarchy.

In order to understand the difference, you should understand the difference between class and object. This is the heart of OO theory and you can read about it in any OO book or simply google it.

As a quick help, here is a simple example of both hierarchies and both (class and object):

A class hierarchy refers to a taxonomy of classes based on inheritance relationships between them - in the following example all classes under the Vehicle (excluding Engine and Wheel), directly or indirectly inherited from it are forming a class hierarchy: enter image description here

Objects are instances of classes, so they "live" on another level of abstraction (e.g. in run-time). Classes are templates for creating their concrete instances - objects. Objects connect themselves and this network of interconnected object form object hierarchy. Here, the objects Car, Engine and 4 Wheels are inteconnected in a object hierarchy: enter image description here

Upvotes: 3

Related Questions