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:

Wenona
2 days ago
Haha, the problem says 'choose all that apply', so I'm going to mark all of them just to be safe! Better too many than too few, right?
upvoted 0 times
...
Lenna
7 days ago
I think option B is the correct answer. Comparing the object's 'a' member directly should allow the multimap to sort the keys properly.
upvoted 0 times
...
Valene
14 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
19 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
24 days ago
I think option A will allow the code to compile and display the desired output.
upvoted 0 times
...

Save Cancel
az-700  pass4success  az-104  200-301  200-201  cissp  350-401  350-201  350-501  350-601  350-801  350-901  az-720  az-305  pl-300  

Warning: Cannot modify header information - headers already sent by (output started at /pass.php:70) in /pass.php on line 77