Hi all,
I am playing around with list and I figure out how to merge two lists and all. But I have no idea how can I integrate one list onto another. For example A = {1,2,3,4,10,11} and B = { 5,6,7} Then my integrated list should be
{1,5,2,6,3,7,4,10}. I would have figured out of two lists are of the same length but they aren't. Two lists can be varied in terms of size.
I am writing a free function so here is my approach :
#include <iostream>
#include <list>
using namespace std;
template <class T>
T integrateList(const& list<T> i, const& list<T> m)
{
list<T>::const_iterator iter;
what exactly do I need to do here?I know how I Can merge the two list?
But how can I integrate or collate them?
}
int main()
{
list<int> listA;
list<int> listB;
list<int> newList;
listA.push_back(1);
listA.push_back(2);
listA.push_back(3);
listA.push_back(4);
listA.push_back(10);
listA.push_back(11)
listB.push_back(5);
listB.push_back(6);
listB.push_back(7);
newList = integrateList(listA, listB);
cout<<newList <<endl;
return 0;
}
Thank you for any help.