ucompos2.cpp
ucompos2.cpp
#include ‹iostream.h›
#include ‹math.h›
#include ‹stl.h›
struct square_root: public unary_function‹double, double› {
square_root() {}
double operator() (double x_) const {return sqrt(x_);}
};
int input[3] = {-1, -4, -16};
int main() {
int output[3];
transform(input, input + 3, output, compose1(square_root(), negate‹int›()));
for (int i = 0; i ‹ 3; i++) cout ‹‹ output[i] ‹‹ endl;
return 0;
}