What happens when you attempt to compile and run the following code?
#include <iostream>
#include <algorithm>
#include <set>
using namespace std;
struct Even {
bool operator ()(int a) {
return (a % 2)==0?true:false;
}
};
int main () {
int t[] = {1,2,3,2,3,5,1,2,7,3,2,1,10, 4,4,5};
set<int> s(t,t+15);
int number = count_if(s.begin(), s.end(), Even());
cout<< number<<endl;
return 0;
}
Program outputs:
Comments