[dcl.ptr] (original) (raw)

[Example 1:

The declarationsconst int ci = 10, *pc = &ci, *const cpc = pc, **ppc;int i, *p, *const cp = &i;declareci, a constant integer;pc, a pointer to a constant integer;cpc, a constant pointer to a constant integer;ppc, a pointer to a pointer to a constant integer;i, an integer;p, a pointer to integer; andcp, a constant pointer to integer.

The value ofci,cpc, andcpcannot be changed after initialization.

The value ofpccan be changed, and so can the object pointed to bycp.

Examples of some correct operations arei = ci;*cp = ci; pc++; pc = cpc; pc = p; ppc = &pc;

Examples of ill-formed operations areci = 1; ci++; *pc = 2; cp = &ci; cpc++; p = pc; ppc = &p;

Each is unacceptable because it would either change the value of an object declaredconstor allow it to be changed through a cv-unqualified pointer later, for example:*ppc = &ci; *p = 5;

— _end example_]