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:

Casie
1 months ago
I'm just going to close my eyes and randomly pick an answer. It's probably the only way I'll get this right. Maybe I should've brought a magic 8-ball with me to the exam.
upvoted 0 times
Adelina
7 days ago
I know, this code is tricky. Good luck with your answer!
upvoted 0 times
...
Adelina
17 days ago
Just take a guess, it's worth a shot.
upvoted 0 times
...
...
Antonio
2 months ago
This question is definitely not for the faint of heart. I'm going to have to think carefully about this one. Maybe I should've taken that 'Introduction to C++ Containers' course after all.
upvoted 0 times
Denise
12 days ago
User 3
upvoted 0 times
...
Margurite
13 days ago
User 2
upvoted 0 times
...
Mindy
1 months ago
User 1
upvoted 0 times
...
...
Bronwyn
2 months ago
Wait, what? I thought the 'includes' function was used to check for inclusion in a vector or set, not a deque. Oh well, I'll just guess 'D) 0 1' and see what happens.
upvoted 0 times
Angelyn
12 days ago
User 3
upvoted 0 times
...
William
14 days ago
User 2
upvoted 0 times
...
Johnetta
1 months ago
User 1
upvoted 0 times
...
...
Delmy
2 months 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
Alida
1 days ago
I believe it's B) 1 1
upvoted 0 times
...
Gerry
5 days ago
I'm leaning towards D) 0 1
upvoted 0 times
...
Wynell
9 days ago
I think the answer is A) 1 0
upvoted 0 times
...
...
Soledad
2 months ago
But why do you think it's D)?
upvoted 0 times
...
Audry
2 months ago
I disagree, I believe the answer is D) 0 1.
upvoted 0 times
...
Soledad
2 months ago
I think the answer is B) 1 1.
upvoted 0 times
...
Cristy
2 months ago
But why do you think so?
upvoted 0 times
...
Isaiah
2 months ago
I disagree, I believe the answer is B) 1 1
upvoted 0 times
...
Oretha
2 months 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
Glory
1 months ago
The code compiles without errors and the output should be '1 1'.
upvoted 0 times
...
Glory
2 months 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
...
Yvonne
2 months ago
So, the correct answer would be B) 1 1.
upvoted 0 times
...
Yvonne
2 months 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
2 months 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