Storage duration specifiers

来自cppreference.com
< cpp‎ | language

 
 
C++语言
大会的主题
原文:
General topics
这段文字是通过 Google Translate 自动翻译生成的。
您可以帮助我们检查、纠正翻译中的错误。详情请点击这里
流量控制
原文:
Flow control
这段文字是通过 Google Translate 自动翻译生成的。
您可以帮助我们检查、纠正翻译中的错误。详情请点击这里
条件执行语句
原文:
Conditional execution statements
这段文字是通过 Google Translate 自动翻译生成的。
您可以帮助我们检查、纠正翻译中的错误。详情请点击这里
迭代语句
原文:
Iteration statements
这段文字是通过 Google Translate 自动翻译生成的。
您可以帮助我们检查、纠正翻译中的错误。详情请点击这里
跳转语句
原文:
Jump statements
这段文字是通过 Google Translate 自动翻译生成的。
您可以帮助我们检查、纠正翻译中的错误。详情请点击这里
功能
原文:
Functions
这段文字是通过 Google Translate 自动翻译生成的。
您可以帮助我们检查、纠正翻译中的错误。详情请点击这里
函数声明
lambda函数的声明
函数模板
的历史。内嵌说明
异常规范 (已弃用)
noexcept说明 (C++11)
例外
原文:
Exceptions
这段文字是通过 Google Translate 自动翻译生成的。
您可以帮助我们检查、纠正翻译中的错误。详情请点击这里
命名空间
原文:
Namespaces
这段文字是通过 Google Translate 自动翻译生成的。
您可以帮助我们检查、纠正翻译中的错误。详情请点击这里
类型
原文:
Types
这段文字是通过 Google Translate 自动翻译生成的。
您可以帮助我们检查、纠正翻译中的错误。详情请点击这里
decltype specifier (C++11)
规范
原文:
Specifiers
这段文字是通过 Google Translate 自动翻译生成的。
您可以帮助我们检查、纠正翻译中的错误。详情请点击这里
CV符
存储时间说明符
constexpr说明 (C++11)
汽车符 (C++11)
alignas说明 (C++11)
初始化
原文:
Initialization
这段文字是通过 Google Translate 自动翻译生成的。
您可以帮助我们检查、纠正翻译中的错误。详情请点击这里
原文:
Literals
这段文字是通过 Google Translate 自动翻译生成的。
您可以帮助我们检查、纠正翻译中的错误。详情请点击这里
布尔文字
nullptr (C++11)
用户定义的 (C++11)
表达式
原文:
Expressions
这段文字是通过 Google Translate 自动翻译生成的。
您可以帮助我们检查、纠正翻译中的错误。详情请点击这里
另一种表示形式
实用工具
原文:
Utilities
这段文字是通过 Google Translate 自动翻译生成的。
您可以帮助我们检查、纠正翻译中的错误。详情请点击这里
类型
原文:
Types
这段文字是通过 Google Translate 自动翻译生成的。
您可以帮助我们检查、纠正翻译中的错误。详情请点击这里
typedef declaration
声明类型别名 (C++11)
属性 (C++11)
施放
原文:
Casts
这段文字是通过 Google Translate 自动翻译生成的。
您可以帮助我们检查、纠正翻译中的错误。详情请点击这里
隐式转换
const_cast conversion
static_cast conversion
dynamic_cast conversion
reinterpret_cast conversion
C-风格和功能转换
内存分配
原文:
Memory allocation
这段文字是通过 Google Translate 自动翻译生成的。
您可以帮助我们检查、纠正翻译中的错误。详情请点击这里
原文:
Classes
这段文字是通过 Google Translate 自动翻译生成的。
您可以帮助我们检查、纠正翻译中的错误。详情请点击这里
类特定的功能特性
原文:
Class-specific function properties
这段文字是通过 Google Translate 自动翻译生成的。
您可以帮助我们检查、纠正翻译中的错误。详情请点击这里
虚函数
覆盖说明 (C++11)
最后说明 (C++11)
明确的 (C++11)
静态的
特殊的成员函数
原文:
Special member functions
这段文字是通过 Google Translate 自动翻译生成的。
您可以帮助我们检查、纠正翻译中的错误。详情请点击这里
模板
原文:
Templates
这段文字是通过 Google Translate 自动翻译生成的。
您可以帮助我们检查、纠正翻译中的错误。详情请点击这里
类模板
函数模板
模板特化
参数包 (C++11)
杂项
原文:
Miscellaneous
这段文字是通过 Google Translate 自动翻译生成的。
您可以帮助我们检查、纠正翻译中的错误。详情请点击这里
内联汇编
 
  • auto - “自动”存储的时间。 (已弃用)
    原文:
    auto - automatic storage duration. (已弃用)
    这段文字是通过 Google Translate 自动翻译生成的。
    您可以帮助我们检查、纠正翻译中的错误。详情请点击这里
  • register - “自动”存储的时间。也暗示编译器将处理器的寄存器中的变量。 (已弃用)
    原文:
    register - automatic storage duration. Also hints to the compiler to place the variable in the processor's register. (已弃用)
    这段文字是通过 Google Translate 自动翻译生成的。
    您可以帮助我们检查、纠正翻译中的错误。详情请点击这里
  • static - “静态”的贮藏期和“内部”联动
    原文:
    static - static storage duration and internal linkage
    这段文字是通过 Google Translate 自动翻译生成的。
    您可以帮助我们检查、纠正翻译中的错误。详情请点击这里
  • extern - “静态”的贮藏期和“外部”的联动
    原文:
    extern - static storage duration and external linkage
    这段文字是通过 Google Translate 自动翻译生成的。
    您可以帮助我们检查、纠正翻译中的错误。详情请点击这里
  • thread_local - “话题”存储时间。 (C++11 起)
    原文:
    thread_local - thread storage duration. (C++11 起)
    这段文字是通过 Google Translate 自动翻译生成的。
    您可以帮助我们检查、纠正翻译中的错误。详情请点击这里

目录

[编辑] 解释

[编辑] 储存时间

所有的变量在程序中有以下存储持续时间
原文:
All variables in a program have one of the following storage durations:
这段文字是通过 Google Translate 自动翻译生成的。
您可以帮助我们检查、纠正翻译中的错误。详情请点击这里
  • 自动'的存储时间。在封闭的代码块的开头的变量被分配和释放就结束。所有非全局变量的存储期限,申报者外staticexternthread_local.
    原文:
    automatic storage duration. The variable is allocated at the beginning of the enclosing code block and deallocated on end. All non-global variables have this storage duration, except those declared static, extern or thread_local.
    这段文字是通过 Google Translate 自动翻译生成的。
    您可以帮助我们检查、纠正翻译中的错误。详情请点击这里
  • '“静态”的存储时间。变量在程序开始时分配和释放程序结束时。只有一个实例存在的变量。所有的全局变量有这样的存储时间,再加上​​那些声明的staticextern.
    原文:
    static storage duration. The variable is allocated when the program begins and deallocated when the program ends. Only one instance of the variable exists. All global variables have this storage duration, plus those declared with static or extern.
    这段文字是通过 Google Translate 自动翻译生成的。
    您可以帮助我们检查、纠正翻译中的错误。详情请点击这里
  • “”线“”的存储时间(C++11 起)。变量线程开始时分配和释放的线程结束时。每个线程都有它自己的实例的变量。只有声明的变量thread_local有这样的存储时间。 thread_local只能被声明为全局变量,再加上,那些与static声明或extern.
    原文:
    thread storage duration (C++11 起). The variable is allocated when the thread begins and deallocated when the thread ends. Each thread has its own instance of the variable. Only variables declared thread_local have this storage duration. thread_local can only be declared for global variables, plus those declared with static or extern.
    这段文字是通过 Google Translate 自动翻译生成的。
    您可以帮助我们检查、纠正翻译中的错误。详情请点击这里
  • 动态'的存储时间。该变量被分配和释放的每个请求使用动态内存分配功能的.
    原文:
    dynamic storage duration. The variable is allocated and deallocated per request by using 动态内存分配 functions.
    这段文字是通过 Google Translate 自动翻译生成的。
    您可以帮助我们检查、纠正翻译中的错误。详情请点击这里

[编辑] 联动

连接是指一个变量或函数被称为在其他范围内的能力。如果具有相同标识符的变量或函数的声明在几个范围,但不能被称为从所有这些,那么所产生的几个实例变量。以下联系确认
原文:
Linkage refers to the ability of a variable or function to be referred to in other scopes. If a variable or function with the same identifier is declared in several scopes, but cannot be referred to from all of them, then several instances of the variable are generated. The following linkages are recognized:
这段文字是通过 Google Translate 自动翻译生成的。
您可以帮助我们检查、纠正翻译中的错误。详情请点击这里
  • 没有任何联系“。”可以被称为变量的范围是自动,线程和动态存储时间长。所有的变量,这种联系.....
    原文:
    no linkage. The variable can be referred to only from the scope it is in. All variables with automatic, thread and dynamic storage durations have this linkage.
    这段文字是通过 Google Translate 自动翻译生成的。
    您可以帮助我们检查、纠正翻译中的错误。详情请点击这里
  • 内部联动。变量可以被称为当前转换单元中的所有范围。所有的变量与静态存储持续时间宣布static,或const,但不extern​​,有这样的联系.
    原文:
    internal linkage. The variable can be referred to from all scopes in the current translation unit. All variables with static storage duration which are either declared static, or const but not extern, have this linkage.
    这段文字是通过 Google Translate 自动翻译生成的。
    您可以帮助我们检查、纠正翻译中的错误。详情请点击这里
  • 外部链接。变量可以被称为在其他的翻译单元的范围。所有的变量具有静态存储持续时间有这种联系,但不申报者外static,或constextern.
    原文:
    external linkage. The variable can be referred to from the scopes in the other translation units. All variables with static storage duration have this linkage, except those declared static, or const but not extern.
    这段文字是通过 Google Translate 自动翻译生成的。
    您可以帮助我们检查、纠正翻译中的错误。详情请点击这里

[编辑] 关键字

auto, register, static, extern, thread_local

[编辑] 示例