Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Yeah that can be quite complicated since the <code>*</code> is used for many different purposes in C/C++.</p> <p>If <code>*</code> appears in front of an already declared variable/function, it means either that:</p> <ul> <li>a) <code>*</code> gives access to the value of that variable (if the type of that variable is a pointer type, or overloaded the <code>*</code> operator).</li> <li>b) <code>*</code> has the meaning of the multiply operator, in that case, there has to be another variable to the left of the <code>*</code></li> </ul> <p>If <code>*</code> appears in a variable or function declaration it means that that variable is a pointer:</p> <pre><code>int int_value = 1; int * int_ptr; //can point to another int variable int int_array1[10]; //can contain up to 10 int values, basically int_array1 is an pointer aswell which points to the first int of the array //int int_array2[]; //illegal, without initializer list.. int int_array3[] = {1,2,3,4,5}; // these two int int_array4[5] = {1,2,3,4,5}; // are indentical void func_takes_int_ptr1(int *int_ptr){} // these two are indentical void func_takes int_ptr2(int int_ptr[]){}// and legal </code></pre> <p>If <code>&amp;</code> appears in an variable or function declaration, it generally means that that variable is an reference to an variable of that type.</p> <p>If <code>&amp;</code> appears in front of an already declared variable, it returns the address of that variable</p> <p>Additionally you should know, that when passing an array to a function, you will always have to pass the array size of that array aswell, except when the array is something like a 0-terminated cstring (char array).</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. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    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