Question
Design three function templates that will be used to process dynamic arrays of different data types. These three function templates should be defined within the
Design three function templates that will be used to process dynamic arrays of different data types. These three function templates should be defined within the namespace named Darrs. Please note that the array of a specific data type and its size will be passed to each function template when it is called. The following function templates are required: - First function template will be used to sort arrays of different data types in both descending and ascending order. This function template is required to have the following parameters: an array of a generic/template type, an integer representing the size of the array, and a character representing the order of sorting (i.e., ascending or descending). The last argument (i.e., the order of sorting) is required to be a default argument. Make up your own default value for this argument. The default order of sorting should be ascending. - Second function template that will be used to display an array of any data type. - Third function template that will count the number of occurrences of a given value in the array. Please note that the array and the value to search for will be passed to the function template in addition to the array size. The template will return an integer value which is the counter that represents the number of occurrences of the given value in the array. Design the main program that can be used to test/ use all of the three function templates above. The program should display the following main menu first: Please select one of the following options:
1. Process integer numbers
2. Process decimal numbers
3. Process characters
4. Exit program
When the option 1, 2, or 3 is selected the program will create a dynamic array of the selected type, where the requested number of values will be entered by the user and stored into the array. The program will then call all three function templates to sort the array, display the array after sorting, and count and display the number of occurrences in the array of the value which is also entered by the user. Please note that before calling the function to sort the array the user has to select the order of sorting (i.e., descending/ascending) for each type of the array. It is required to check for the dynamic memory allocation error and handle this error.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started