/* Filename: templat4.cpp Author: Br. David Carlson Date: August 2, 2003 This program uses a template function with two generic types. The function simply prints the two values, one after the other, on the same line. This test program uses this function to print an error message, a warning message, and a string followed by a number. Tested with: Microsoft Visual C++ 2019 */ #include using namespace std; /* Given: First An item of type TypeA. Second An item of type TypeB. Task: To print First followed by Second on the same line. Assumes: That data of TypeA and TypeB can be output with <<. Return: Nothing. */ template void Output2(TypeA First, TypeB Second) { cout << First << " " << Second << endl; } int main(void) { float Total = 142.35; // We could use this function to print an error message: Output2("Error:", "No data was supplied."); // Similarly, we could use it to print a warning: Output2("Warning:", "You are using an out-of-date version of this software."); // However, we can also use the function to output items having different types: Output2("The total is:", Total); return 0; }