/*
 * @topic T00353 May 2 -- swap function
 * @brief Program demonstrates using pointers and references
*/

// function taking pointers to integers
void swap( int* x, int* y )
{
    if ( x == y ) return; // if same int in memory, ignore
    int tempx = *x;
    *x = *y;
    *y = tempx;
}

// function taking references to integers
void swap( int& x, int& y )
{
    if ( &x == &y ) return; // if same int in memory, ignore
    int tempx = x;
    x = y;
    y = tempx;
}

int main()
{
    int one = 1;
    int two = 2;
    swap( &one, &two ); // swap using pointers
    swap( one, two ); // swap using references
    return 0;
}