logo
  • 教程列表
  • SO官方文檔
  • 變數宣告關鍵字
    • decltype
    • 常量
    • 籤
    • 無符號
    • 揮發物
  1. StackOverflow 文件
  2. C++ 教程
  3. 變數宣告關鍵字
  4. 常量

常量

Created: November-22, 2018

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

Copyright © 2018. All right reserved

tastones.com 备案号:鲁ICP备18045372号-1

  • 關於本站
  • 免責聲明