title: How to use c++ swap function?
body: <p>When I write like this <code>swap(a,b);</code> it is ok.</p>
  
  <p>When I write like this <code>swap(&amp;c[0],&amp;d[0]);</code> there is a error.
  Somebody can tell me why?</p>
  
  <pre class="lang-cpp prettyprint-override"><code>#include&lt;iostream&gt;
  #include&lt;algorithm&gt;
  using namespace std;
  
  int main(void){
      int *a;
      int *b;
      int c[]={1,2};
      int d[]={3,4};
      a=&amp;c[0];
      b=&amp;d[0];
      swap(a,b);// it is ok
      //swap(&amp;c[0],&amp;d[0]);// it is error why
      cout&lt;&lt;a[0]&lt;&lt;" "&lt;&lt;b[0]&lt;&lt;endl;
      cin.get();
  }
  </code></pre>