Changes between Version 4 and Version 5 of const


Ignore:
Timestamp:
May 13, 2010, 4:57:49 PM (10 years ago)
Author:
andersk@mit.edu
Comment:

Try to clarify the table by distinguishing between “changing” a char and “repointing” a pointer.

Legend:

Unmodified
Added
Removed
Modified
  • const

    v4 v5  
    44
    55||`const int x;`[[br]]`int const x;`||The value of the `int` cannot be changed.||
    6 ||`const int *p;`[[br]]`int const *p;`||The value of the `int` cannot be changed through this pointer.||
    7 ||`int *const p;`||The value of the pointer cannot be changed.||
    8 ||`const int *const p;`||The value of the pointer cannot be changed, and the value of the `int` cannot be changed through this pointer.||
     6||`const int *p;`[[br]]`int const *p;`||The value of the `int` cannot be changed through this pointer (`*p = n` is disallowed).||
     7||`int *const p;`||The pointer cannot be repointed (`p = q` is disallowed).||
     8||`const int *const p;`||The pointer cannot be repointed, and the value of the `int` cannot be changed through this pointer.||
    99||`const int a[3];`||The values of the `int`s in the array cannot be changed.||
    1010||`const char **pp;`||The `char` pointed to by `*pp` cannot be changed through it.||
    11 ||`char *const *pp;`||The `char *` pointed to by `pp` cannot be changed through it.||
    12 ||`char **const pp;`||`pp` cannot be changed.||
    13 ||`const char *const *pp;`||The `char *` cannot be changed through `pp`, and the `char` cannot be changed through `*pp`.||
     11||`char *const *pp;`||The `char *` pointed to by `pp` cannot be repointed through it.||
     12||`char **const pp;`||`pp` cannot be repointed.||
     13||`const char *const *pp;`||The `const char *` cannot be repointed through `pp`, and the `char` cannot be changed through `*pp`.||
    1414||`const char *const *const pp;`||All of the above.||
    1515