-
nyoobee
Q: A Company has many departments. an Employee of a company is associated with one department.Each department has a manager, the manager is one of the employees only.Create the necessary inheritance hierarchy and classes for the company.
Ans: as given by teacher
Class Company {/////}
Class Department: public Company
Class Employee : public Department
Class Manager : public Employee
Izzis correct ???...cause I dint thinkzo
How Exactly r v supposed to represent a one-to-many or many-to-many relationship in classes ?
-
Code:
class Employee { };
class Manager : Employee { };
class Department {
Manager leader;
vector<Employee> workers;
};
class Company {
vector<Department> depts;
};
Or something similar I would think...