Todos los libros

Profesional

Apps Acerca de Coach Iniciar sesión Empezar a leer

Computer Science · Glosario

¿Qué es Lifetime; automatic, static and global variables?

También llamado: lifetime (of a variable) · automatic variable · static variable · global variable

Definition 3.9 University Computer Science — Year 1 · Capítulo 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.

Leer en el capítulo →