C++ List swap()C++ List swap() function exchange the contents of the list with another list of same type but the sizes can be differ. SyntaxParameterx: It is an another list which is to be exchanged with the given list. Return valueIt does not return any value. Error:It throws an error, when both the list are of different type. Example 1Let's see a simple example when both the list are of same type and same size. Output: Initially,content of list li is : +-*@ Initially,content of list li1 is : java After swapping, content of list li is : java After swapping, content of list li1 is : +-*@ In this example, swap() function swaps the contents of list li with the list li1. Example 2Let's see a simple example when both the list are of different type. Output: error : no matching call for list::swap(list&). In this example, both the list are of different type. Therefore, the function swap() throws an error i.e : no matching call for list::swap(list&). Next Topicreverse() Function |
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India