Class string provides member function swap for swapping strings. Figure 21.4 swaps two strings. Lines 8–9 declare and initialize strings first and second. Each string is then output. Line 14 uses string member function swap to swap the values of first and second. The two strings are printed again to confirm that they were indeed swapped. The string member function swap is useful for implementing programs that sort strings.