plz help me in understanding how m i suppose to maintain the list and wat will be the structure of following code???
Write a C++ program that represents an HOD-Faculty relationship in an academic institution using public inheritance. C++ program should provide following operations, only through member functions, no constructor/destructor should be used.
a. Add a faculty or HOD.
b. Maintain a common list (use static allocation) for both HODs and Faculties.
c. Display all the Faculties (including HOD who is also a Faculty) with respect to their names.
Assume faculty attributes as Faculty ID and Faculty Name, while attributes of the HOD as Department Name.
what I see from this "homework" assignment, I might start with something like:
1 2 3 4 5 6 7 8 9 10 11 12
class facultyMember
{
protected:
string name;
string classTaught;
// bla bla bla
};
class HeadOfDepartment : public facutlyMember
{
// head of department specific stuff...
};
The main reason every person is a faculty member, but only a few are Head of Departments.
When I use the list it would be listed as all faculty, and I would cast to put HOD's on it.
Its actually after making class i got stuck what i am suppose to do...if i made objects of both the class faculty member and head of department and take inpput from user depending on choice whether to enter faculty or HOD then to maintain a common list should i used pointer to base class and use virtual display function and a friend function arrange in base class .... is this right?????????
k... thanks i was not thinking of making maintain_list function as faculty member function... but one thing y are u making this member function as virtual??
vector<HOD > fac; should be protected member of Cfaculty, as it should be accessed by Cfaculty
as well as HOD class. an object of Cfaculty class should also update vector<HOD > fac.
the question says that though hod inherits from faculty ... there can be some objects of faculty only which are not HOD.... as per ur code there is only HOD objects....
i have made a program without using STL plz see to it
#include<cstring>
#include<iostream>
using namespace std;
class faculty
{
protected:
char name[50];
long salary;
char designation[15];
arjita07@ program seems to be fine to me .. thanks ..
but i need to correct and understand the earlear version ( vector version ) . Any suggestion is appreciated .
Thanks again