Implement a template container class that encapsulates a dynamic array and test it using a suitable driver program (You may use one file for your template class instead of breaking it into

computer science

Description

Implement a template container class that encapsulates a dynamic array and test it using a suitable driver program (You may use one file for your template class instead of breaking it into 2 files.)


Your class should include the following data members: 

• A pointer to the array 

• A variable to hold the current array capacity (capacity) 

• A variable to keep track of the number of elements currently being used. (num_used)


Include 2 constructors (or you can write one constructor with a default value for size): 

• The default constructor dynamically allocates an array of size 10 and initializes capacity to 10 and num_used variable to 0. 

• A one argument constructor dynamically allocates an array of the size passed as an argument and initializes capacity to that number and num_used variable to 0



Include methods to: 

• Determine if the array is full (return a bool value) 

• Determine if the array is empty (return a bool value) 

• Return the array capacity 

• Return the number of elements currently being used


Related Questions in computer science category