C++ Vector swap()This function is used to exchange the elements specified in two vectors. SyntaxConsider two vectors v1 and v2. Syntax would be: Parameterv2: v2 is a vector, whose value is to be swapped with another vector. Return valueIt does not return any value. Example 1Let's see a simple example. Output: Before swapping,elements of v1 are :1 2 3 4 5 Before swapping,elements of v2 are :6 7 8 9 10 After swapping,elements of v1 are :6 7 8 9 10 After swapping,elements of v2 are :1 2 3 4 5 In this example, swap() function exchanges the elements of vector v1 with the vector v2. Next TopicC++ Vector |
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