void swap (int* a, int* b)
{
int temp = 0;
if (a > b)
{
temp = b; // get error on this line
a = b;
temp = a;
}
}
int main ()
{
int a;
int b;
cout << "Please insert integer a.";
cin >> a;
cout << "Please insert integer b.";
cin >> b;
swap (&a, &b);
cout << a << " " << b;
return 0;
}
Though you may want to note that you can make temp equal the contents of whatever b is pointing to; assign temp to whatever b is pointing to rather than the pointer itself.