It is necessary to store an array of external objects in a class, so that when changing in a container class, the objects change not only locally. Without stl. Here is what I have:
class AdultDepartment: virtual public Building{ protected: Patient *places; int *days; int count_places; and here is the method of adding a new object:
void addPerson(Patient &p){ addDays(); Patient *temp; if(places != nullptr){ temp = places; places = new Patient[count_places]; for(int i = 0; i < count_places - 1; i++){ places[i] = temp[i]; } delete []temp; places[count_places - 1] = p; cout << places[count_places - 1].getName() << endl; } else{ places = new Patient[1]; places[0] = p; cout << places[0].getName() << endl; } }
count_placesnot updatecount_placeswhen adding!), and when fully filled in, increase it, say, 2 times - well, by the principle of vector operation in STL. - Harry