Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The first important piece of information is that parameters whose type is a (bounded or unbounded) array of <code>T</code> are transformed to pointers to <code>T</code>. I.e. both <code>int arr[]</code> and <code>int arr[10]</code> are transformed to <code>int * arr</code>. Note that the transformation is only performed on top-level arrays, i.e. it doesn't occur in <code>int (*arr)[10]</code>, which is a pointer to an array of int.</p> <p>Furthermore, things to the right of the identifier bind more closely than things to the left, i.e. <code>int *arr[10]</code> is an array, whereas <code>int (*arr)[10]</code> is a pointer.</p> <p>Lastly, arrays of and pointers to references are invalid, as are pointers and references to unbounded arrays.</p> <pre><code>1. void foo(int &amp;arr); // can't pass, reference to int 2. void foo(int &amp;arr[]); // invalid, pointer to reference to int 3. void foo(int (&amp;arr)[]); // invalid, reference to unbounded array of int 4. void foo(int &amp;arr[10]); // invalid, pointer to reference to int 5. void foo(int (&amp;arr)[10]); // can pass, reference to an array of int 6. void foo(int *arr); // can pass, pointer to int 7. void foo(int *arr[]); // can't pass, pointer to pointer to int 8. void foo(int (*arr)[]); // invalid, pointer to an unbounded array of int. 9. void foo(int *arr[10]); // can't pass, pointer to pointer to int 10. void foo(int (*arr)[10]); // can't pass, pointer to array of int 11. void foo(int arr[]); // can pass, pointer to int 12. void foo(int arr[10]); // can pass, same as above </code></pre> <p>Using <code>arr</code> as an argument to <code>foo</code> will cause it to decay to a pointer to its first element -- the value passed to <code>foo</code> will be of type <code>int *</code>. Note that you can pass <code>&amp;arr</code> to number 10, in which case a value of type <code>int (*)[10]</code> would be passed and no decay would occur.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload