//---------------------------------------------------------------------------- // // FILE : passing_fxns.C DEMO PROGRAM // AUTHOR : Eugene Wallingford // CREATION DATE : April 17, 1997 // //---------------------------------------------------------------------------- #include void print_stars(int val) { for (int i = 0; i < val; i++) cout << '*'; cout << endl; } void print_value(int val) { cout << '*' << val << '*' << endl; } void handle_value(int n, void printer(int)) { cout << "Value is " << n << " - "; printer(n); } void main () { int choice; cout << "Enter your favorite integer: "; cin >> choice; handle_value(choice, print_stars); handle_value(choice, print_value); } /*------------------------------------------------------------------------* * * * SAMPLE RUN: * * * * nova > g++ passing_fxns.C * * nova > a.out * * Enter your favorite integer: 42 * * Value is 42 - ****************************************** * * Value is 42 - *42* * * * *------------------------------------------------------------------------*/