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 8 Question 68 Discussion

Actual exam question for C++ Institute's CPP exam
Question #: 68
Topic #: 8
[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() {

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

B t1[]={B(1),B(2),B(3),B(4)};

deque d1(t, t+10);

set s1(t, t+10);

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

cout<

<

return 0;

}

Program outputs:

Show Suggested Answer Hide Answer
Suggested Answer: E

Contribute your Thoughts:

Soledad
9 hours ago
I think the answer is B) 1 1.
upvoted 0 times
...
Cristy
2 days ago
But why do you think so?
upvoted 0 times
...
Isaiah
3 days ago
I disagree, I believe the answer is B) 1 1
upvoted 0 times
...
Oretha
4 days ago
The code should compile without any errors, and the output should be '1 1', as the 'includes' function checks if all elements in the second range (t1) are present in the first range (d1 and s1).
upvoted 0 times
...
Cristy
6 days ago
I think the answer is A) 1 0
upvoted 0 times
...