How to create a List with Constructor in C++ STL
Lists are sequence containers that allow non-contiguous memory allocation. As compared to vector, list has slow traversal, but once a position has been found, insertion and deletion are quick. Normally, when we say a List, we talk about doubly linked list. For implementing a singly linked list, we use forward list.
A list can be created with the help of constructor in C++. The syntax to do it is:
list<type> list_name(size_of_list, value_to_be_inserted);
Below programs show how to create a List with Constructor in C++.
100 100 100 100 100 100 100 100 100 100
Geeks Geeks Geeks Geeks Geeks