Write a template function to fill in a STL list with a given
Write a template function to fill in a STL list with a given array.
Solution
Hi, I am not able to see the function prototype completely.
But I wrote a function that takes a template array and adding all elements of array in STL list.
Please let me know in case of any issue.
template<typename T >
void fillArray(T arr[], int size) {
// creating STL list of type T
std::list<T> myList;
// adding each element from arr in list
for(int i=0; i<size; i++){
myList.push_back(arr[i]);
}
}
