The Swap Program with Pointers
#include <iostream.h>
// Prototype for our swap function
// Use pointers instead of references
void swap(int *x, int *y);
void main()
{ int FirstInt = 10;
int SecondInt = 20;
// We must pass the address of each
//variable when we call the swap
swap(&FirstInt, &SecondInt);
}
Previous slide
Next slide
Back to first slide
View graphic version