Question: Consider the incomplete code below and indicate which of the code ( i ) will: Modify the targetList using the splice function to move elements

Consider the incomplete code below and indicate which of the code (i) will:
Modify the targetList using the splice function to move elements from the sourceList as indicated in the comment.
#include
#include
int main()
{
std::list sourceList ={8,9,4};
std::list targetList ={5,1,3};
//result targetList should be {5,1,3,8,9,4}
//--(i)--
std::cout << "Modified targetList
";
for (int item : targetList){
std::cout << item <<"";
}
}
a.
targetList.splice(targetList.end(), sourceList);
b.
targetList.splice(targetList.begin(), sourceList);
c.
targetList.splice(targetList.begin(), sourceList, sourceList.begin());
d.
targetList.splice(targetList.end(), sourceList, sourceList.begin());

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!