To illustrate this better let s take the example of a classroom, a teacher, and a student. A classroom contains several students and one teacher therefore a classroom will contain one teacher object and several student objects in the member variables of the classroom object. The students might be contained in a linked list or an array. Since every student has a teacher and a classroom identifiers for those objects will exist in student objects. A teacher object, on the other hand might only have an identifier for the classroom and have access to the classroom function that accesses students.
Inheritance is when an object receives some or all of the attributes of another object.
Some relationships rely heavily on inheritance. This happens when the functions needed are left as public in the principal class and the teacher class making reference to them. Examples of these include office staff, actual classrooms, the kitchen staff, and the janitorial staff. While each of these environments share the common link of existing within the school, the way each is run is going to be different. This is where each department will have different member functions that will determine how things flow when something happens.