// C++ example 21-9-99 part 3 corporation.cpp #include #include #include "legalentity.h" #include "person.h" #include "corporation.h" corporation::corporation(string n, string a, person *p): legalentity(n,a) { president=p; numemployees=0; } string corporation::tostring(void) { return name+" at "+address; } person *corporation::getpresident(void) { return president; } void corporation::changepresident(person *p) { president=p; } int corporation::getnumemployees(void) { return numemployees; } person *corporation::getemployee(int i) { if (i<0 || i>=numemployees) return NULL; return employees[i]; } void corporation::employ(person *p) { if (numemployees>=100) { cerr << "too many employees for "+name+"\n"; exit(1); } employees[numemployees]=p; numemployees+=1; p->setemployer(this); } void corporation::printall(void) { cout << "Corporation: " << tostring() << "\n"; cout << " President: " << president->tostring() << "\n"; cout << " " << numemployees << " employees:\n"; for (int i=0; itostring() << "\n"; }