ucompos1.cpp
ucompos1.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, unary_compose‹square_root, negate‹int› ›(square_root(), negate‹int›()));
for (int i = 0; i ‹ 3; i++) cout ‹‹ output[i] ‹‹ endl;
return 0;
}