Problem statement: A learning environment contains both students and staffs who have attributes in common because they are both people. In some institutions a student may also be working as a staff there at the same time. The implications of the above stated in Object Oriented Programming is:
StudentinheritsPersonStaffinheritsPerson- In some instances, a
Studentobject and aStaffobject should both be built on the samePersoninstance(I.e share the same parent class instance)
How do I implement the last implication on the list using OOP? (C#, Java, C++, or Python preferably)
I don't think that inheritence is the right solution to your problem. Is it necessary that
StudentandStaffare different classes?It seems that it would be more appropriate that a student or a staff member are just instances of
Person, and there is a member propertyrolewhich may contain"Student"or"Staff"or both.