C++ Institute C++ Certified Professional Programmer CPP Question # 63 Topic 7 Discussion

C++ Institute C++ Certified Professional Programmer CPP Question # 63 Topic 7 Discussion

CPP Exam Topic 7 Question 63 Discussion:
Question #: 63
Topic #: 7

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() {

string t[]={"aaa","Aaa", "aAa","aaA","bbb","Bbb", "bBb", "bbB"};

vector v1(t, t+8);

sort(v1.begin(), v1.end());

for_each(v1.begin(), v1.end(), Out(cout));cout<

return 0;

}

Program outputs:


A.

Aaa Bbb aAa aaA aaa bBb bbB bbb


B.

Aaa aAa Bbb aaA aaa bBb bbB bbb


C.

bBb bbB bbb Aaa aAa Bbb aaA aaa


D.

Aaa aAa bBb bbB bbb Bbb aaA aaa


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.