Three template functions are to be created.
The first template function is to output the content of an array.
The second template function sorts the array.
The third template function exchanges the respective values (for sorting). Use the function ÒCall-By-ReferenceÓ.
First the output is to be sorted, then the array is sorted and then the sorted values are output.
Test your program using an integer array and a string array.
The user can decide how many integer values are sorted. For example, if he/she enters "5", 5 random numbers are generated, stored in the array, then output, then sorted and finally the sorted values are output again.
In the string array, for example, you can store 3 strings directly.
Hint:
You must pass an array and its number of elements to the template functions "Sort" and "Output".
The addresses of the variables to be swapped are passed to the template function "Swap". A pointer is used in this function.
\ No newline at end of file
Three template functions are to be created.
The first template function is to output the content of an array.
The second template function sorts the array.
The third template function exchanges the respective values (for sorting). Use the function "Call-By-Reference".
First the output is to be sorted, then the array is sorted and then the sorted values are output.
Test your program using an integer array and a string array.
The user can decide how many integer values are sorted. For example, if he/she enters "5", 5 random numbers are generated, stored in the array, then output, then sorted and finally the sorted values are output again.
In the string array, for example, you can store 3 strings directly.
Hint:
You must pass an array and its number of elements to the template functions "Sort" and "Output".
The addresses of the variables to be swapped are passed to the template function "Swap". A pointer is used in this function.