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:

Delmy
5 days ago
Hmm, this looks like a tricky one. I'm going to go with 'B) 1 1' and hope I got it right. If not, maybe I can blame it on the caffeine shortage in the test center.
upvoted 0 times
...
Soledad
8 days ago
But why do you think it's D)?
upvoted 0 times
...
Audry
10 days ago
I disagree, I believe the answer is D) 0 1.
upvoted 0 times
...
Soledad
11 days ago
I think the answer is B) 1 1.
upvoted 0 times
...
Cristy
12 days ago
But why do you think so?
upvoted 0 times
...
Isaiah
14 days ago
I disagree, I believe the answer is B) 1 1
upvoted 0 times
...
Oretha
15 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
Yvonne
3 days ago
It should output '1 1' because the 'includes' function checks if all elements in the second range are present in the first range.
upvoted 0 times
...
...
Cristy
16 days ago
I think the answer is A) 1 0
upvoted 0 times
...
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