C++ Institute CPP Question Answer
What happens when you attempt to compile and run the following code?
#include
#include
#include
#include
using namespace std;
template
ostream & out;
Out(ostream & o): out(o){}
void operator() (const T & val ) { out< struct Sequence { int start; Sequence(int start):start(start){} int operator()() { return start++; } }; int main() { vector generate_n(v1.begin(), 10, Sequence(1)); random_shuffle(v1.rbegin(), v1.rend()); sort(v1.begin(), v1.end(), great for_each(v1.begin(), v1.end(), Out return 0; } Program outputs: