Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><code>Type const* p</code> is a pointer to const object with type <code>Type</code>. To be read left to right, with pointer pointing to type defined by everything before the star. The same way, <code>Type const* const q</code> is a const pointer to a const object with type <code>Type</code>. </p> <p>Also, <code>*p</code> cannot be modified through p. <code>p</code> is defined so as to const-point to <code>*p</code> and promise not to modify it. However, <code>*p</code>, p's pointee, can be modified by any other pointer pointing at it. </p> <p>For example, we can have</p> <pre><code>Type t; Type const* pc = &amp;t; Type *pnc = &amp;t; </code></pre> <p><code>pc</code> promises not to alter t, <code>pnc</code> does not. Let's say class Type bears a const <code>inspect() const</code> method and a non-const <code>mutate()</code> method. Then we could have</p> <pre><code>pc-&gt;inspect(); pnc-&gt;inspect(); pnc-&gt;mutate(); </code></pre> <p>whereas this one would rise compiler's error:</p> <pre><code>pc-&gt;mutate(); </code></pre> <p><code>Type const* const q</code> is a pointing to a const object and <code>*q</code> cannot be modified through q, just like with p. What is more, pointer <code>q</code> cannot be modified: it cannot be assigned a pointee a second time.</p> <p><em><strong>Also, although this may sounds very strange, you are allowed to change in code the object of type <code>Type</code> pointed by pointer <code>Type const* p</code> -- but not through <code>p</code>.</em></strong></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.
    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