progs/swap.cpp

The following code example is taken from the book
Object-Oriented Programming in C++
by Nicolai M. Josuttis, Wiley, 2002
© Copyright Nicolai M. Josuttis 2002


#include <iostream>
#include "swap.hpp"

int main()
{
    int x = 7;
    int y = 13;

    std::cout << "x: " << x                  // x: 7,  y: 13
              << "  y: " << y << std::endl;

    swap (x, y);                             // swaps values of x and y

    std::cout << "x: " << x                  // x: 13,  y: 7
              << "  y: " << y << std::endl;
}