CPP practice question 3 of 30

What happens when you attempt to compile and run the following code? #include #include using namespace std; bool mycomparison (int first, int…

Choose your answer, then check it against the explanation.

What happens when you attempt to compile and run the following code? #include #include using namespace std; bool mycomparison (int first, int second){return first>second;} 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(mycomparison); l2.sort(mycomparison); l1.merge(l2,mycomparison); print(l1.begin(), l1.end()); print(l2.begin(), l2.end()); cout<<endl; return 0; }
Answer options
Question 3 of 30

Keep practicing

Take the free CPP practice test

Ten exam-style questions with answers and explanations, plus the exam facts and study guides.

Start the free practice test

More questions

Other CPP practice questions

Scroll to Top