It is OK to write swap(a,b);
There is an issue when I write swap(&c[0],&d[0]);.
Can anyone explain why?
#include<iostream>
#include<algorithm>
using namespace std;
int main(void){
int *a;
int *b;
int c[]={1,2};
int d[]={3,4};
a=&c[0];
b=&d[0];
swap(a,b);// it is ok
//swap(&c[0],&d[0]);// it is error why
cout<<a[0]<<" "<<b[0]<<endl;
cin.get();
}