//Use template to sort and print an array, with function prototype #include #include using namespace std; //function prototypes: template void show(T a[], int count); template void bubbleSort(T a[], int count); int main() { int num[] = { 20, 5, 3, 17, 2 }; int count = sizeof(num) / sizeof(int); cout << "There are " << count << " integers\n"; bubbleSort(num, count); show(num, count); double d[] = { 5.5, -20, 0.25, 6.1 }; count = sizeof(d) / sizeof(double); cout << "There are " << count << " doubles\n"; bubbleSort(d, count); show(d, count); string name[] = { "Mary", "Bill", "Amy", "Jay", "Mike", "Alex" }; count = sizeof(name) / sizeof(string); cout << "There are " << count << " names\n"; bubbleSort(name, count); show(name, count); system("pause"); return 0; }//main //function definitions: template void show(T a[], int count) { for (int i = 0; i void bubbleSort(T a[], int count) { //A very inefficient bubble sort for (int i = 0; ia[j + 1]) swap(a[j], a[j + 1]); } //j inner loop }//i outer loop } //show