C++ Institute C++ Certified Professional Programmer CPP Question # 26 Topic 3 Discussion

C++ Institute C++ Certified Professional Programmer CPP Question # 26 Topic 3 Discussion

CPP Exam Topic 3 Question 26 Discussion:
Question #: 26
Topic #: 3

What happens when you attempt to compile and run the following code?

#include

#include

#include <algorithm>

#include

using namespace std;

templatestruct Out {

ostream & out;

Out(ostream & o): out(o){}

void operator() (const T & val ) { out<

int main() {

int t[]={3,2,4,1,5,6,10,8,7,9};

vector v1(t, t+10);

for_each(v1.begin(), v1.end(), bind2nd(plus(), 1));

for_each(v1.rbegin(), v1.rend(), Out(cout));cout<

return 0;

}

Program outputs:


A.

3 2 4 1 5 6 10 8 7 9


B.

4 3 5 2 6 7 11 9 8 10


C.

9 7 8 10 6 5 1 4 2 3


D.

10 8 9 11 7 6 2 5 3 4


E.

compilation error


Get Premium CPP Questions

Contribute your Thoughts:


Chosen Answer:
This is a voting comment (?). It is better to Upvote an existing comment if you don't have anything to add.