The Wayback Machine - https://web.archive.org/web/20130629052855/http://zh.cppreference.com:80/w/cpp/language/storage_duration

Storage duration specifiers

来自cppreference.com

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

目录

[编辑] 解释

[编辑] 储存时间

所有的变量在程序中有以下存储持续时间
Original:
All variables in a program have one of the following storage durations:
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
  • 自动'的存储时间。在封闭的代码块的开头的变量被分配和释放就结束。所有非全局变量的存储期限,申报者外staticexternthread_local.
    Original:
    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.
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
  • '“静态”的存储时间。变量在程序开始时分配和释放程序结束时。只有一个实例存在的变量。所有的全局变量有这样的存储时间,再加上​​那些声明的staticextern.
    Original:
    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.
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
  • “”线“”的存储时间(C++11 起)。变量线程开始时分配和释放的线程结束时。每个线程都有它自己的实例的变量。只有声明的变量thread_local有这样的存储时间。 thread_local只能被声明为全局变量,再加上,那些与static声明或extern.
    Original:
    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.
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
  • 动态'的存储时间。该变量被分配和释放的每个请求使用动态内存分配功能的.
    Original:
    dynamic storage duration. The variable is allocated and deallocated per request by using 动态内存分配 functions.
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.

[编辑] 联动

连接是指一个变量或函数被称为在其他范围内的能力。如果具有相同标识符的变量或函数的声明在几个范围,但不能被称为从所有这些,那么所产生的几个实例变量。以下联系确认
Original:
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:
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
  • 没有任何联系“。”可以被称为变量的范围是自动,线程和动态存储时间长。所有的变量,这种联系.....
    Original:
    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.
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
  • 内部联动。变量可以被称为当前转换单元中的所有范围。所有的变量与静态存储持续时间宣布static,或const,但不extern​​,有这样的联系.
    Original:
    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.
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
  • 外部链接。变量可以被称为在其他的翻译单元的范围。所有的变量具有静态存储持续时间有这种联系,但不申报者外static,或constextern.
    Original:
    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.
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.

[编辑] 关键字

auto, register, static, extern, thread_local

[编辑] 为例