C++ Variable Declaration Keywords const


A type specifier; when applied to a type, produces the const-qualified version of the type. See const keyword for details on the meaning of const.

const int x = 123;
x = 456;    // error
int& r = x; // error

struct S {
    void f();
    void g() const;
const S s;
s.f(); // error
s.g(); // OK