Deal of The Day! Hurry Up, Grab the Special Discount - Save 25% - Ends In 00:00:00 Coupon code: SAVE25
Welcome to Pass4Success

- Free Preparation Discussions

C++ Institute Exam CPP Topic 1 Question 85 Discussion

Actual exam question for C++ Institute's CPP exam
Question #: 85
Topic #: 1
[All CPP Questions]

Which changes introduced independently will allow the code to compile and display ''one'' ''eight'' ''nine'' ''ten''? Choose all that apply.

#include

#include

#include

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(){

int t[] ={ 3, 4, 2, 1, 6, 5, 7, 9, 8, 10 };

string s[] = {"three", "four", "two", "one", "six","five", "seven", "nine","eight","ten"};

multimap m;/* Replace Code Here 3 */

for(int i=0; i<10; i++) {

m.insert(pair(A(t[i]),s[i]));

}

m.erase(m.lower_bound(2),m.upper_bound(7));

multimap::iterator i=m.begin();/* Replace Code Here 4 */

for( ; i!= m.end(); i++) {

cout<second<<" ";

}

cout<

return 0;

}

Show Suggested Answer Hide Answer
Suggested Answer: C

Contribute your Thoughts:

Valene
4 days ago
Hmm, you might be right. Let's see which option actually works when we try to compile the code.
upvoted 0 times
...
Pauline
9 days ago
I disagree, I believe option D is the correct choice because it provides the necessary comparison function for the multimap.
upvoted 0 times
...
Valene
13 days ago
I think option A will allow the code to compile and display the desired output.
upvoted 0 times
...

Save Cancel