常量

类型说明符; 应用于类型时,生成该类型的 const 限定版本。有关 const 含义的详细信息,请参阅 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