CI

C++ Certified Professional Programmer

228 Questions

You can start the exam to practice all questions related to this exam.

Question No. 1

What will happen when you attempt to compile and run the code below, assuming that you enter

the following sequence: 1 2 3 end<enter>?

#include <iostream>
#include <string>
#include <list>
#include <algorithm>

using namespace std;

template<class T>struct Out {
ostream & out;
Out(ostream & o): out(o){}
void operator() (const T & val ) {out<<val<<" "; } };

int main ()
{
list<int> l;
for( ; !cin.bad() ; )
{
int i;
cin>>i;
l.push_back(i);
}
for_each(l.begin(), l.end(), Out<int>(cout));
return 0;
}
Choose the correct option from the given list.
01 / 228

0 Discussions

Trending Exams