নেগেট ফাংশন প্রদত্ত মানগুলিকে অস্বীকার করার জন্য ব্যবহার করা হয় যেমন মানগুলির চিহ্ন পরিবর্তন করতে। এটি নেতিবাচক মানগুলিকে ইতিবাচক এবং বিপরীতে পরিবর্তন করে৷
ফাংশন প্রোটোটাইপ:
function transform(a_begin, a_end, a1_begin, negate()): a_begin = lower bound of the array. a_end = upper bound of the array. a1_end = Lower bound of the second modified array. negate() = to negate the values of the array.
উদাহরণ কোড
#include <algorithm>
#include <functional>
#include <iostream>
using namespace std;
int main() {
int a[] = { 4,6,7, -10, -20, -30 };
transform(a, a + 6, a, negate<int>());
for (int i = 0; i < 6; i++)
cout << a[i] << ' ';
return 0;
} আউটপুট
-4 -6 -7 10 20 30