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; } } 
  • Where did the strange “no STL” claim come from? - VladD
  • one
    Probably by analogy with boost ("you have to drag the whole stl !!!") - Vladimir Gamalyan
  • It seems to me that it would be more logical to store pointers to objects - then there would be no question about "the objects changed not only locally." It makes sense to reserve some amount of memory for future objects, i.e. store the size of the array and its filling (by the way, you count_places not update count_places when adding!), and when fully filled in, increase it, say, 2 times - well, by the principle of vector operation in STL. - Harry
  • @VladD usually such restrictions come from student assignments, but in the end it all comes down to creating your own STL with blackjack. In this case, some vector <shared_ptr>. - αλεχολυτ
  • @Harry in addDays () increase - saninstein

0