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

Last Updated on December 6, 2021 by Admin 2

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

#include <vector>
#include <iostream>
#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() {
int t[]={3,2,4,1,5,10,9,7,8,6};
vector<int> v1(t,t+10);
cout<<*max_element(v1.begin(), v1.end());
return 0;
}

Program outputs:

  • 3
  • 1
  • 6
  • 10
  • compilation error
0 0 votes
Article Rating
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments