C++ String swap()
This function is used to exchange the values of two string objects.
Consider two strings s1 and s2 , we want to exchange the values of these two string objects. Its syntax would be :
It contains single parameter, whose value is to be exchanged with that of the string object.
It does not return any value.
Before swap r contains 10 rupees Before swap m contains 20 rupees After swap r contains 20 rupees After swap m contains 10 rupees
In this example, r and m are two string objects containing 10 and 20 rupees respectively. We swap there values by using swap function. After swapping, r contains 20 rupees and m contains 10 rupees.
Next TopicC++ Strings
JavaTpoint offers too many high quality services. Mail us on h[email protected], to get more information about given services.
JavaTpoint offers college campus training on Core Java, Advance Java, .Net, Android, Hadoop, PHP, Web Technology and Python. Please mail your requirement at [email protected].
Duration: 1 week to 2 week