#include #include #include using namespace std; /*----------- Class BCCCommunity starts ---------------*/ class BCCCommunity { friend ostream & operator<<(ostream &, BCCCommunity &); friend istream & operator>>(istream &, BCCCommunity &); private: string name; int emplid; public: BCCCommunity(string = "Unknown", int = 0); ~BCCCommunity(); void setName(string &); void setID(int &); string getName() const; int getID() const; }; BCCCommunity::BCCCommunity(string na, int ID) :name{na}, emplid{ID} { } BCCCommunity::~BCCCommunity() { } void BCCCommunity::setName(string &na) { name=na; } void BCCCommunity::setID(int &ID) { emplid=ID; } string BCCCommunity::getName() const { return name; } int BCCCommunity::getID() const { return emplid; } ostream & operator<<(ostream & ost, BCCCommunity & sta) { ost << left <<"BCC member's name: " << setw(20) << sta.getName() << " EMPLID: " << setw(12) << sta.getID(); return ost; } istream & operator>>(istream & ist, BCCCommunity & sta) { cout << "BCC member's name: "; getline(ist,sta.name); cout << "EMPLID: "; ist >> sta.emplid; ist.ignore(); return ist; } /* -------- CLASS TEACHER STARTS ---------*/ class Teacher : virtual public BCCCommunity { private: string classteaching; public: friend ostream & operator<<(ostream & , Teacher & ); friend istream & operator>>(istream &, Teacher &); Teacher(string = "Unknown", int = 0, string = "Unknown"); void setClassTeaching(string &); string getClassTeaching(void) const; }; ostream & operator<<(ostream & ost, Teacher & sta) { ost << left <<"Name: " << setw(20) << sta.getName() << " EMPLID: " << setw(12) << sta.getID() << "Teaching classes: " << setw(20) << sta.getClassTeaching(); return ost; } istream & operator>>(istream & ist, Teacher & sta) { cout << "Teacher's name: "; string temp; getline(ist,temp); sta.setName(temp); cout << "EMPL ID: "; int temp2; ist >> temp2; sta.setID(temp2); cout << "Teaching classes: "; ist.ignore(); getline(ist, sta.classteaching); return ist; } Teacher::Teacher(string na, int ID, string cls) : BCCCommunity(na,ID), classteaching{cls} { } void Teacher::setClassTeaching(string & cls) { classteaching = cls; } string Teacher::getClassTeaching(void) const { return classteaching; } /*-----------------Class Student starts ---------------*/ int main() { BCCCommunity joe; cin >> joe; cout << joe << endl; Teacher me; cin >> me; cout << me << endl; // Student you; // cin >> you; // cout << you << endl; // Tutor her; // cin >> her; // cout << her << endl; }