// CS2310 Exercise 18 // // Name ________________________ SSN ________________ // // Chapter 17 p1012 - 3, 4 // Write a function template for a void function, GetData, that // receives a string through the parameter list, uses that string // to prompt the user for input, reads a value from the keyboard, // and returns that value (as a reference parameter) through the // parameter list. The data type of the input value can be any // type for which the >> operator is defined. // // Assume you have an enumeration type // // enum AutoType {SEDAN, COUPE, OTHER}; // // Write a user-defined specialization of the GetData template // that accomodates the AutoType type. For input, the user should // type the character 's' for sedan, 'c' for coupe, and 'o' (or // anything else) otherwise. #include using namespace std; enum AutoType {SEDAN, COUPE, OTHER}; // Write function definition for GetData here. int main() { int i; float f; char c; // Call the function for an integer GetData("Please type an integer: ", i); cout << "The returned integer is: " << i << endl; // Call the function for a float GetData("Please type a real number: ", f); cout << "The returned real number is: " << f << endl; // Call the function for a character GetData("Please type a character to indicate the autotype: ", c); // Write code here to print the proper enumerator depending // on the character read. 's' is for sedan, 'c' for coupe, and // 'o' and anything else for others. return 0; }