Item07. Const Pointers and Pointers to Const
Due to the formation of a variety of glazings, a constant pointer, a constant pointer, pointing to a constant pointer, pointing to a constant pointer to constant, pointing to a constant pointer to a constant ------------------------------------------------------------------------------------------------------ ------------------------------------------ appearance: 1, difference: by const Decision T * const CPT = Pt; // Const PTR to T constant pointer T * pct = pt; // ptr to const t pointing to a constant pointer 2, reading: self-right left 3, t const * PCT = Pt; and const t * pct = pt; is a thing of the god: Who is const? Const Pointers: The pointer is constant, can no longer point to other objects, but the point to the object value is a variable Pointers to const: the object pointing to the object, can point to other objects, but point to the object value pointing to the target value does not change of------------------------------------------------- --------------- Q: 1, Const Pointers and non-const pointers The conversion problem with Non-const Pointers can be implicitly converted into const pointers (for example, as a function of the parameter). Conversely, it is necessary to display forced conversion (if the object pointing to Const Pointers is a constant, converting to non-const power, it will destroy the const attribute of the object to which it is pointing, so it is best to use Const_cast display) It seems that there is a simple, There is no more trouble. 2, const pointers to constly bundle together, don't change it.