Exam CPP Topic 1 Question 153 Discussion

Actual exam question for C++ Institute's CPP exam
Question #: 153
Topic #: 1
Which changes introduced independently will allow code to compile and display 0 1 8 9 (choose all that apply)
#include <iostream>
#include <set>
#include <vector>
using namespace std;
class A {
int a;
public:
A(int a):a(a){}
int getA() const { return a;}
/* Insert Code Here 1 */
};
/* Insert Code Here 2 */
int main(){
A t[] ={ 3, 4, 2, 1, 6, 5, 7, 9, 8, 0 };
vector<A>v(t, t+10);
set<A> s1(v.begin(),v.end());
s1.insert(v.begin(),v.end());
s1.erase(s1.lower_bound(2),s1.upper_bound(7));
for(set<A>::iterator i=s1.begin();i!= s1.end(); i++) {
cout<<i?>getA()<<" ";
}
cout<<endl;
return 0;
}

Suggested Answer: A,B,C Vote an answer

by Marcia at Aug 22, 2026, 04:56 PM

Comments

Chosen Answer:
This is a voting comment (?) , you can switch to a simple comment.
Switch to a voting comment New
Nick name: Submit Cancel
A voting comment increases the vote count for the chosen answer by one.

Upvoting a comment with a selected answer will also increase the vote count towards that answer by one. So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.

0
0
0
10