C++之

C++之 const

北慕城南 提交于 2020-11-23 10:00:09
In the C, C++, and D programming languages, const is a type qualifier, a keyword applied to a data type that indicates that the data is constant (does not vary). While this can be used to declare constants, const in the C family of languages differs from similar constructs in other languages in being part of the type, and thus has complicated behavior when combined with pointers, references, composite data types, and type-checking. const was introduced by Bjarne Stroustrup in C with Classes, the predecessor to C++, in 1981, and was originally called readonly.As to motivation, Stroustrup writes