Question: Write a class named 'Directory'. This class will be used to manage an integer index. The maximum size of the array can be limited to

Write a class named 'Directory'. This class will be used to manage an integer index. The maximum size of the array can be limited to 10000. In the 'private' part an integer index and a counter will be defined. All remaining functions will be located in the 'public' section. The member functions are explained below,

(i) The function named 'Count' will return the current number of elements in the array.

(ii) The function 'fetch' will take the index of the array as a parameter and return the index element in that index. If there is no element in the given index number, it will return NULL.

(ili) The function named 'add' will return nothing and will add value to the index. It will take two parameters, the first parameter to be an integer to be indexed, and the second parameter to specify the position (index) of the value to be appended. If the second parameter is not sent to the function, the integer value (first parameter) will be appended to the end of the array. Do not write an overloaded function for this operation, instead use the default value for the second parameter. (iv) The function 'remove' will return nothing and will remove elements from the array. It will get the position (index) of the element to be removed from the index. If the given index points to a non-elemental location, the function will do nothing.

Important Note: After using the 'add' and 'remove' functions, the sorted index format must not be broken. If there are gaps in between, these gaps will be removed in order not to spoil the form.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!