Tasks studies - laboratory
Create an object MY_STUDENT
, which contains the student’s name (use dynamic memory allocation) and the year of commencement of studies.
Place the student support in the files my_student.h
and my_student.cpp
. The object MY_STUDENT
does not know how it will be used, so
it should anticipate use in any mode. This means that the deallocator of this object should free all the memory, allocated
dynamically.
Create a dynamic array MY_STUDENT_GROUP
, each element of which contains a void * pointer for storing data.
Array - CONTAINER MY_STUDENT_GROUP
is created with dynamic memory allocation and does not depend on the type
of stored data. Place the array support in the files my_array.h
and my_array.cpp
.
Table - container does not depend on data, so this means that the table deallocator should completely free the memory, dynamically allocated for each object. At the same time, freeing
data objects that were added to the table should not damage the data stored in the table, and vice versa.
For example, we create an object MY_DATA *ptrdat = CreateData(.....);
and add it to the table-container. Now they should have two
independent copies of data - in the table element and the ptrdat object. Freeing an array element does not damage ptrdat, and freeing ptrdat does not
damage an array element.
The objects MY_STUDENT
and MY_STUDENT_GROUP
are created dynamically.
In the main function:
MY_STUDENT
objects and add them to the dynamic table.MY_STUDENT
objects. This freeing up memory should not damage the data in the CONTAINER.