What happens when you attempt to compile and run the following code?#include <vector>#include <iostream>#include <algori
Posted: Wed Aug 03, 2022 9:20 am
What happens when you attempt to compile and run the following code?#include <vector>#include <iostream>#include <algorithm>#include <functional>using namespace std;template<class T>struct Out {ostream & out;Out(ostream & o): out(o){}void operator() (const T & val ) { out<<val<<" "; } }; int Add(int a, int b) { return a+b;}int main() {int t[]={1,2,3,4,5,6,7,8,9,10};vector<int> v1(t, t+10);vector<int> v2(10);transform(v1.begin(), v1.end(), v2.begin(), bind2nd(ptr_fun (Add),1)); vector<int>::iterator it = find_if(v2.begin(), v2.end(),bind2nd(equal_to<int>(),10)); cout<<*it<<endl; return 0;}Program outputs:
A. false
B. true
C. 10
D. 0 E. compilation error
A. false
B. true
C. 10
D. 0 E. compilation error