ptrbinf1.cpp

We use cookies. Read the Privacy and Cookie Policy

ptrbinf1.cpp

#include ‹iostream.h›

#include ‹stl.h›

int sum(int x_, int y_) {

 return x_ + y_;

}

int input1[4] = {7, 2, 3, 5};

int input2[4] = {1, 5, 5, 8};

int main() {

 int output[4];

 transform(input1, input1 + 4, input2, output, pointer_to_binary_function‹int, int, int›(sum));

 for (int i = 0; i ‹ 4; i++) cout ‹‹ output[i] ‹‹ endl;

 return 0;

}