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 9 Question 90 Discussion

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

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

#include

#include

#include

#include

using namespace std;

class B { int val;

public:

B(int v):val(v){}

int getV() const {return val;} bool operator < (const B & v) const { return val

ostream & operator <<(ostream & out, const B & v) { out<

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);

sort(d1.begin(), d1.end());

set s1(t,t+10);

cout<

return 0;

}

Program outputs:

Show Suggested Answer Hide Answer
Suggested Answer: E

Contribute your Thoughts:

Vashti
6 days ago
I'm not sure, but I think the answer might be D because the first binary_search should return 0 since 4 is not in the set, but the second one should return 1 because 4 is in the deque.
upvoted 0 times
...
Raul
7 days ago
I agree with Jordan, the first binary_search should return 1 since 4 is in the set, but the second one should return 0 because 4 is not in the deque.
upvoted 0 times
...
Jordan
12 days ago
I think the answer is A because binary_search returns 1 if the element is found in the set, and 0 if not.
upvoted 0 times
...