diff --git a/guide/english/cplusplus/lists/index.md b/guide/english/cplusplus/lists/index.md index 963786ae27..f5291d91a7 100644 --- a/guide/english/cplusplus/lists/index.md +++ b/guide/english/cplusplus/lists/index.md @@ -15,18 +15,29 @@ of how Lists are organized compared to Vectors and Arrays. Traversal in a list is slow as compared to Vectors and Arrays, but once a position has been found, insertion and deletion are quick. ## How to declare a List -If you want to declare a List of Numbers you write: -```std::list Numbers;``` +Possible declarations of a list: +```c++ +#include + +int main() +{ + std::list list1 = {1, 2, 3, 4}; + std::list list2 (list1); + std::list list3 = list2; + std::list list4 {list3}; + std::list* list5 = new std::list(list4); +} +``` ## Functions used with List -size() : Returns the number of elements in the list -begin() : Returns an iterator pointing to the first element of the list -end() : Returns an iterator pointing to the theoretical last element which follows the last element -push_front(data) – Adds a new element with value 'data' at the beginning of the list -push_back(data) – Adds a new element with value 'data' at the end of the list -pop_front() – Removes the first element of the list -pop_back() – Removes the last element of the list +* size() : Returns the number of elements in the list +* begin() : Returns an iterator pointing to the first element of the list +* end() : Returns an iterator pointing to the theoretical last element which follows the last element +* push_front(data) – Adds a new element with value 'data' at the beginning of the list +* push_back(data) – Adds a new element with value 'data' at the end of the list +* pop_front() – Removes the first element of the list +* pop_back() – Removes the last element of the list ## How to use these Functions