Reference no: EM1331337
In class, we have been discussing creating objects using the new operator and releasing the memory using the delete operator. Two other similar operators are new[] and delete[]. These operators work the same as the new and delete but with arrays, these are called dynamic arrays:
int size = 5;
// Dynamic arrays don't have to be initialized with constants.
int* ints = new int[size];
// We can rezie the array dynamically.
ints = new int[size];
// Use delete[] to release memory.
delete[] ints;
Create a class Person having the following:
· First name, last name, and middle name with their respective get and set functions. The get functions shall be declared constants.
· A default constructor.
· Overload the operators == and !=. The equality operator shall evaluate to true when the social security numbers are equal. The not equals operator shall evaluate to true when the social security numbers are not equal.
Then use your class Person to create a class RegistrationOffice. This class shall have the following:
· A dynamic array of Person objects. Initially the array will have size 10.
· A function register(Person&). This function will add the specified person to the array. Make sure to check the size of the array and resize it if the array is out of space.
· A function remove(int). This function will search the array for the person having the specified social security and remove it from the array. Make sure to shift the needed elements of the array.
· A function find(int). This function will search the array and return the person having the specified social security.
· A function display(void). This function will display to the screen all the people registered.
· Overload the operator << taking a Person object as parameter. This operator will perform the same logic as register.
· Overload the operator [ ] taking an int as parameter. This operator will perform the same logic as find.
In your driver class, make sure to test all the functions created in both classes.