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 3 Question 16 Discussion

Posted by Filiberto on May 06, 2022 at 03:26 AM

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

#include

#include

int main ()

{

std::vectorv1;

for(int i = 0; i<10; i++) {v1.push_back(i); }

std::vector v2(v1.begin()+2, v1.end()?2);

std::vector::iterator it = v2.begin();

for( ; it != v2.end(); it++) {std::cout<<*it++<<" "; }std::cout<

return 0;

}

Suggested Answer: D

Get Premium CPP Questions as Interactive Web-Based Practice Test or PDF Real Exam Format Detailed Explanations Instant Access Get Your Practice Test
8 comments · newest first
LA
Lashanda 11 months ago
Nah, I think it outputs 2 4 6 instead.
VI
Vivan 12 months ago
It's supposed to output 2 3 4 5 6 7, right?
JA
Jaclyn 12 months ago
Wait, is that really a compilation error? I thought it might run.
CU
Curt 12 months ago
I agree, that line is definitely off!
MI
Mitzie 1 year ago
Looks like a compilation error due to the wrong use of end()?
WE
Weldon 1 year ago
Hmm, I'm a bit confused about the difference between publishing changes and running the solution checker. I'll need to review those steps carefully.
AB
Abraham 1 year ago
This is a tricky one, the privacy statement has a lot of details to parse through. I'm going to re-read it carefully and think through each option before making my final decision.
MA
Margarita 1 year ago
Disabling SSLv3 is a no-brainer for security these days. I'll definitely select that one.
0/2000 characters

Save Cancel