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 CPP Exam - Topic 1 Question 52 Discussion

Posted by Jamal on Jul 26, 2022 at 11:15 PM

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<

B(4))<

return 0;

}

Program outputs:

Suggested Answer: B

Get Premium CPP Questions as Interactive Web-Based Practice Test or PDF Real Exam Format Detailed Explanations Instant Access Get Your Practice Test
13 comments · newest first
RA
Raymon 11 months ago
I doubt it will compile with that deque initialization.
MA
Mabelle 11 months ago
Wait, how does that even work?
MO
Mose 12 months ago
Definitely 0 0, right?
LA
Lavonna 12 months ago
I think the output is 1 1.
RO
Rosalia 12 months ago
The code compiles without errors.
JU
Justine 1 year ago
I feel like there might be a compilation error because of how `deque` is initialized with an array, but I can't remember the specifics.
NO
Novella 1 year ago
I practiced a similar question where we had to check if an element existed in a container, but I can't recall if `binary_search` works on `deque` like it does on `set`.
BO
Bonita 1 year ago
I think the `binary_search` function will return true for the `set` since it's sorted, but I'm not confident about the `deque`.
MA
Malcolm 1 year ago
I remember we discussed how `deque` and `set` handle sorting differently, but I'm not sure how that affects the output here.
IR
Irma 1 year ago
Hmm, I'm not sure about this one. Dulling the teeth or dragging them on the backstroke doesn't sound very safe. Maybe a vise or a handle could work, but I'm leaning towards the gloves.
LO
Louann 1 year ago
I'm going to make an educated guess and select "workflow" as the answer. That seems to capture how the different components of the organization coordinate and complete tasks together. But I'm not 100% sure, so I'll double-check my work before submitting.
MA
Marcelle 1 year ago
I'm not quite sure, but the focus on feelings and discussions seems different from regular testing. Could it be risk-based testing or something else?
RA
Raylene 1 year ago
I'm a little confused by the wording of this question. The options don't seem to directly match the question. I'll need to re-read it a few times to make sure I understand what they're asking.
0/2000 characters