Question: C++. Given the following struct declaration: struct Student { * name; gpa; }; Implement 2 functions: 1. Student ** createStudentList(char ** names, int size); -
C++. Given the following struct declaration:
struct Student
{
* name;
gpa;
};
Implement 2 functions:
1. Student ** createStudentList(char ** names, int size); - function creates an array of pointers to Student objects dynamically. It allocates Student objects and set their name as the passed in names and gpa as 0. size is the number of names available. You can allocate 2*size as many pointers to Student objects just in case you need to add more to the list. For the extra spots in the array, set them to nullptr. The function returns the pointer to the Student pointer array.
2. bool destroyStudentList(Student ** studentList, int size); - function deletes all the Student objects in the array along with their dynamically allocated data members, such as name. It also releases the array of the pointers to the Student objects. The function returns true if the operation is successful and false if studentList contains nullptr.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
