Summary of const

 [Previous Chapter]  [Previous Page]  [Contents]  [Next Page]  [Next Chapter]

const double PI = 3.14159265358979323846;

*Defines PI to be a constant, i.e. its value cannot be changed later on.
 
Point(const Point& p);

*While p is passed by reference (immutable pointer) it must not be changed by Point. This permits better performance (as copying is avoided) without sacrificing security.
 
float get_x() const;

*A const following a method signature declares it formally as accessor that is not allowed to change its object.
 
const Key& get_key();

*The caller is not allowed to modify the value which is returned by reference from get_key.
 

 [Previous Chapter]  [Previous Page]  [Contents]  [Next Page]  [Next Chapter]
Copyright © 2001, 2002 Andreas Borchert, converted to HTML on February 21, 2002