|
-
Apr 6th, 2002, 08:25 AM
#1
Thread Starter
Addicted Member
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 ?
-
Apr 6th, 2002, 08:41 AM
#2
Monday Morning Lunatic
Code:
class Employee { };
class Manager : Employee { };
class Department {
Manager leader;
vector<Employee> workers;
};
class Company {
vector<Department> depts;
};
Or something similar I would think...
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|