CPP practice question 12 of 30

What happens when you attempt to compile and run the following code? #include #include #include using namespace std; class A { int a; public: A(int…

Full set: 228 questions
What happens when you attempt to compile and run the following code? #include #include #include using namespace std; class A { int a; public: A(int a) : a(a) {} int getA() const { return a; } void setA(int a) { this?>a = a; } }; struct Even { bool operator ()(const A & a, const A &b) { return (a.getA() % 2)==b.getA() % 2; } }; int main () { int t[] = {1,2,3,2,3,5,1,2,7,3,2,1,10, 4,4,5}; deque d (t,t+15); deque::iterator it = search_n(d.begin(), d.end(), 3, 2, Even()); cout<< it?d.begin()<<endl; return 0; } Program outputs:
Answer options
A: compilation error
B: 12 Correct answer
C: 3
D: 1
E: 15
Correct Answer:
B. 12
Scroll to Top