// unary_function.cpp // compile with: ////// Structure Used: // unary_function
#include
Using namespace std;
/ * Derive class from unary_function in Order to use it * /
class unary_test: public unary_function
/ * You can now Easily create operator That Accept * // * an int AND return a float. * /
Unary_test :: result_type unary_test :: Operator * (unary_test :: argument_type x) {float tmp = value * (float) x; cout << "ValueAfter * IS" << TMP << endl; return value;}
Unary_test :: result_type unary_test :: Operator- (unary_test :: argument_type x) {float tmp = value - (float) x; cout << "ValueAfter minus is" << TMP << Endl; Return TMP;}
INT main (void) {unary_test item; unary_test item2 (18.0);
COUT << "begin" << Endl; cout.setf; item = item * 2; item2 = item2 - 5; return 0;} / * Output Begin ValueAfter * is 20.000000 ValueAfter Minus IS 13.000000 * /