全部书籍

专业

应用 关于 Coach 登录 开始阅读

书籍暂未推出简体中文版——当前显示英文版。

Computer Science · 术语表

什么是 Lifetime; automatic, static and global variables?

又称: lifetime (of a variable) · automatic variable · static variable · global variable

Definition 3.9 University Computer Science — Year 1 · 第 3 章 — Functions and the Call Stack

The lifetime (or storage duration) of a variable is the part of the run during which it exists and keeps its value. An automatic variable, a parameter or a local declared without static, lives from the entry into its block to the exit from it, in the current frame; each call has its own. A static variable, a local declared with static, has block scope but lives for the whole run, in the data segment, and is initialised once, before main starts. A global variable, declared at file scope, also lives for the whole run, and its name is visible to the whole file.

在原文中阅读 →