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 6 Question 82 Discussion

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

What happens when you attempt to compile and run the following code?

#include

#include

#include

#include

using namespace std;

templatestruct Out {

ostream & out;

Out(ostream & o): out(o){}

void operator() (const T & val ) { out<

int main() {

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

deque d1(t, t+10);

set s1(t,t+10);

cout<

return 0;

}

Choose all possible outputs (all that apply):

Show Suggested Answer Hide Answer
Suggested Answer: B

Contribute your Thoughts:

Frederick
9 hours ago
The code should compile and run without any issues. The output should be '1 0', since the `binary_search` function will return 1 for the set and 0 for the deque, as the set is sorted and the deque is not.
upvoted 0 times
...
Karl
3 days ago
I agree with Jerry. Sets are not sorted, so binary_search won't work on them.
upvoted 0 times
...
Jerry
6 days ago
I think the output will be A) 0 0 because binary_search does not work on sets.
upvoted 0 times
...

Save Cancel