常量

型別說明符; 應用於型別時,生成該型別的 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