In object oriented programming (OOP) , you can build a tree of classes.
For example might be some class A, which is inherited from the class B ,class B which is inherited from the class C.
Please see following image:
http://www.codeproject.com/KB/cpp/386982/standard_composite.GIF
The hierarchy of classes including one parent class and several child nodes.
1) Worker is Node
2) Manager is Node
Please read about the inheritance in C++ or C# or Java