Javatpoint Logo
Javatpoint Logo

list::push_front() and list::push_back() in C++ STL

We know that the C++ programming language is blessed with the pre-defined implementation of Data Structures and Algorithms in its Standard Template Library (STL); if not present, we need to write the whole code, which takes a lot of compilation time for the compiler and a time-consuming process for the programmer sitting opposite to the PC.

The list is one such important Data Structure which is treated as a Container helping us to store the data, which can be of any data type like int, char, string, long, short etc. The push_front() operation helps us add the elements to the List Data Structure we have created, and the push_back() function allows us to add up the features or the data from the back of the List Data Structure.

Syntax

C++ code

Output:

/ t m  p  / d J J Y Z f g 6J u.o
// Output of the List created
6 1 2 3 4 5

C++ code

Output:

/ t m  p  / d J J Y Z f g 6J u.o
6 7 24 43 45 58 89

C++ code

Output:

/ t m  p  / d J J Y Z f g 6J u.o
1 2 3 4 5 6

C++ code

Output:

6 7 24 43 45 58 89






Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA