C++ Institute C++ Certified Professional Programmer CPP Question # 18 Topic 2 Discussion

C++ Institute C++ Certified Professional Programmer CPP Question # 18 Topic 2 Discussion

CPP Exam Topic 2 Question 18 Discussion:
Question #: 18
Topic #: 2

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

#include

#include

#include

using namespace std;

template void print(T start, T end) {

while (start != end) {

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

}

}

int main() {

string t1[] ={ "1", "2", "3", "4", "5", "6", "7", "8", "9", "10"};

list l1(t1, t1 + 10);

list l2(l1);

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

l1.unique();

print(l1.begin(), l1.end()); cout<

return 0;

}


A.

compilation error


B.

program outputs: 1 2 3 4 5 6 7 8 9 10 9 8 7 6 5 4 3 2 1


C.

program outputs: 1 2 3 4 5 6 7 8 9 10 10 9 8 7 6 5 4 3 2 1


D.

program outputs: 1 2 3 4 5 6 7 8 9 10


Get Premium CPP Questions

Contribute your Thoughts:


Chosen Answer:
This is a voting comment (?). It is better to Upvote an existing comment if you don't have anything to add.