In the example given they state a department can have a teacher and if a department goes out of scope/deconstructs it doesnt destroy the teacher that was in that department. for example in real life departments at different school change names,get added,and get deleted all the time. Just because a department gets deleted doesn't mean they also fire/delete the teachers. My question is i understand this perfectly fine( or so i think as i just described ) but the problem i see with aggregation compositional classes is the following. Say you have the same example given from the website posted above but instead departments have MULTIPLE teachers.
How are you supposed to deal with teachers that are no longer hired? do you just check the address of the pointer and if it's set to 0 you know you need to remove them from the department?
You will have tons of dynamically allocated teachers. How do you manage all of them will i need to create another class in order to do so? if i had done regular class composition this wouldn't have been a problem correct and only 1 class would be needed?