title: Error when passing list by reference (C++)
body: <p>I'm trying to write a subroutine in C++ to take the location of one cell on a square grid and return a list of its' neighbours, so for most cells it will return 4 neighbours, but cells on the edge will only have 3 and in the corner will only have 2. I'm not a very proficient C++ programmer, so I looked up some help on here for passing the list by reference (<a href="https://stackoverflow.com/questions/9302645/c-pass-list-as-a-parameter-to-a-function">C++ pass list as a parameter to a function</a>).</p>
  
  <p>I get this error: </p>
  
  <pre><code>In function ‘void findNeighbours(int, int, int, int, std::list&lt;int, std::allocator&lt;int&gt; &gt;&amp;)’:
  
  error: invalid conversion from ‘int*’ to ‘int’
  </code></pre>
  
  <p>Here is my code:</p>
  
  <pre><code>void findNeighbours(int x, int y, int xSIZE, int ySIZE, list&lt;int&gt;&amp; neighbours){
    int n[2]={x-1,y};
    int e[2]={x,y+1};
    int s[2]={x+1,y};
    int w[2]={x,y-1};
    switch(x){
      case 0: {neighbours.push_back(s);}
      case xSIZE-1: {neighbours.push_back(n);}
      default: {neighbours.push_back(n);neighbours.push_back(s);}
    }
    switch(y){
      case 0: {neighbours.push_back(e);}
      case ySIZE-1: {neighbours.push_back(w);}
      default: {neighbours.push_back(e);neighbours.push_back(w);}
    }
  }
  </code></pre>
  
  <p>The line causing the error appears to be this line: 
      case 0: {neighbours.push_back(s);}</p>
  
  <p>but I can't see what I'm doing differently to the example I looked up (linked above).</p>
  
  <p>As I said, I'm not the most proficient C++ coder, so please explain in a simple language as you can. I'm used to using Python so I'm not very good with pointers etc.</p>
  
  <p>Thanks in advance for your help,</p>
  
  <p>FJC</p>