Lists are containers used in C++ to store data in a non contiguous fashion, Normally, Arrays and Vectors are contiguous in nature, therefore the insertion and deletion operations are costlier as compared to the insertion and deletion option in Lists.
This operator is used to assign new contents to the container by replacing the existing contents.
It also modifies the size according to the new contents.
listname1 = (listname2) Parameters : Another container of the same type. Result : Assign the contents of the container passed as parameter to the container written on left side of the operator.
Input : mylist1 = 1, 2, 3 mylist2 = 3, 2, 1, 4 mylist1 = mylist2; Output : mylist1 = 3, 2, 1, 4 Input : mylist1 = 2, 6, 1, 5 mylist2 = 3, 2 mylist1 = mylist2; Output : mylist1 = 3, 2
Errors and Exceptions
1. If the containers are of different types, an error is thrown.
2. It has a basic no exception throw guarantee otherwise.
mylist1 = 3 2 1 4
- Find the node whose sum with X has minimum set bits
- Salt and Pepper Noise removal using C++
- Dynamic Constructor in C++ with Examples
- C++ Stream Classes Structure
- OpenMP | Hello World program
- Odd Even Transposition Sort / Brick Sort using pthreads
- Chat application between two processes using signals and shared memory
- Find k closest numbers in an unsorted array
- Intel Graphics Software Engineer Interview Experience
- OpenMP | Introduction with Installation Guide
- Equation of straight line passing through a given point which bisects it into two equal line segments
- Maximum absolute difference in an array
- Count the pairs of vowels in the given string
- Why overriding both the global new operator and the class-specific operator is not ambiguous?
- Print path from root to all nodes in a Complete Binary Tree
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.