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 101 Discussion

Actual exam question for C++ Institute's CPP exam
Question #: 101
Topic #: 8
[All CPP Questions]

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

#include

#include

using namespace std;

template

void print(T start, T end) {

while (start != end) {

std::cout << *start << " "; start++;

}

}

int main()

{

int t1[] ={ 1, 7, 8, 4, 5 };

list l1(t1, t1 + 5);

int t2[] ={ 3, 2, 6, 9, 0 };

list l2(t2, t2 + 5);

l1.sort();

list::iterator it = l2.begin();

it++; it++;

l1.splice(l1.end(),l2, it, l2.end());

print(l1.begin(), l1.end()); cout<<"Size:"<

print(l2.begin(), l2.end()); cout<<"Size:"<

return 0;

}

Show Suggested Answer Hide Answer
Suggested Answer: B

Contribute your Thoughts:

Jessenia
2 days ago
Hmm, I see your point. Let's wait for more opinions before deciding.
upvoted 0 times
...
Lizette
3 days ago
I disagree, I believe the answer is C) program outputs: 1 3 4 5.
upvoted 0 times
...
Jessenia
13 days ago
I think the answer is A) program outputs: 1 2 4 5.
upvoted 0 times
...

Save Cancel