吃什么东西可以降压| 什么是炎症| 为什么都说头胎很重要| 电子烟有什么危害| 陈醋和蜂蜜一起喝有什么好处| 撩是什么意思| 果丹皮是用什么做的| 66年属马是什么命| 4月1号是什么星座| 耳门有痣代表什么| 胸闷气短吃什么特效药| 忍冬是什么意思| 张飞的兵器是什么| 树冠是什么| 梦见旅游是什么意思| 1995年的猪五行属什么| 广州为什么叫花城| 尿白细胞3十什么意思| 小跟班是什么意思| 狂犬疫苗什么时候打有效| 智齿是什么| 粉刺长什么样图片| 去疤痕挂什么科| 唇钉是干什么用的| 70岁是什么之年| 猫咪打呼噜代表什么| 什么叫柏拉图式的爱情| 纠结是什么意思| 11年属什么| 肛裂吃什么药| 7.13什么星座| 吃什么改善睡眠| 梅核气吃什么药最好| 哈乐是什么药| 什么样的西瓜| 乳腺彩超什么时候做最准确| 讲义气是什么意思| 1955年是什么年| cd是什么元素| 腿疼膝盖疼是什么原因| 糖耐什么时候检查| 贫血到什么程度会晕倒| 抗酸杆菌是什么| 公认是什么意思| 眼睛干涩有异物感用什么眼药水| 嘴角裂口是什么原因怎么办| 重庆五行属什么| 誉之曰的之是什么意思| 梦到门坏了是什么意思| 拉肚子可以吃什么食物| 真菌感染脚气用什么药| 幽门梗阻是什么意思| 为什么晚上睡不着觉| 免疫球蛋白适合什么人| 什么是水印照片| 双肺纹理增粗是什么意思| 白细胞酯酶阳性是什么意思| 穗字五行属什么| 汧是什么意思| 艾是什么意思| 挪揄是什么意思| 是非是什么意思| 90岁叫什么| 单核细胞百分比偏高说明什么| 带量采购是什么意思| 月下老人什么意思| 结婚36年是什么婚| 侬是什么意思| 外阴白斑是什么引起的| 颈椎压迫神经吃什么药| 什么时候可以上环最好的| 肝ca什么意思| 小猫发烧有什么症状| 什么不同成语| 年糕是什么做的| 脾胃气虚吃什么中成药| 不可名状的名是什么意思| 什么是特殊膳食| 虾皮不能和什么一起吃| 德国人是什么人种| 小姨子是什么关系| 888红包代表什么意思| 鼻子下面长痘什么原因| 红薯什么季节成熟| 肾上腺结节挂什么科| 姨妈是什么意思| 疰夏是什么意思| 欧是什么意思| 什么力竭| 额是什么意思| me是什么基团| 海市蜃楼是什么现象| feat什么意思| 霜降是什么意思| 60年属什么| 双侧中耳乳突炎是什么意思| 送情人什么礼物最好| 大姨妈来了吃什么好| lotus是什么牌子| 淋巴结肿大是什么样子| 海带排骨汤海带什么时候放| 借条和欠条有什么区别| 红斑狼疮有什么症状| 什么是优质蛋白| 胃疼和肚子疼有什么区别| 型式检验是什么意思| 邻家女孩什么意思| 腋下发黑是什么原因| 磁共振是查什么的| 黄痰吃什么药最好| 新生儿贫血是什么原因造成的| 雷震子是什么神位| 酉是什么字| 石斛什么价格| 松茸是什么东西| 吃什么能排毒体内毒素| 送对象什么礼物好| 尿血挂什么科| 什么时候闰五月| 地道战在河北什么地方| 喝茶是什么意思| 橙字五行属什么| 数九寒天是什么意思| 身体缺钾是什么原因造成的| 头皮痛是什么原因| 频繁打哈欠是什么原因| 蚧壳虫用什么药最有效| 天蝎座什么象星座| 2015属什么| 北面属于什么档次| 孩子脚后跟疼是什么原因| 桥本甲状腺炎有什么症状表现| cp是什么意思| 口业是什么意思| 12月生日是什么星座| 化学阉割什么意思| 竹子可以做什么| 打豆豆什么意思| 什么白酒好喝| 网球大满贯什么意思| 心悸是什么意思啊| 整装待发是什么意思| pe材质是什么| 海底椰是什么| 烤瓷牙和全瓷牙有什么区别| 嗓子痒咳嗽是什么原因| 春是什么生肖| 吃什么水果对肾有好处| 吃什么食物可以降尿酸| 赤小豆是什么| 6月26是什么星座| 刘邦字什么| 晶莹剔透是什么意思| 痛苦的反义词是什么| 门的单位是什么| 角膜炎吃什么消炎药| 性激素是什么意思| bf是什么意思| 斩金念什么| 属牛本命佛是什么佛| 匈奴是现在的什么民族| 阳字属于五行属什么| 为什么怀不上孩子| 皮毒清软膏有什么功效| 月经为什么会推迟| 北京的区长是什么级别| hcy是什么检查项目| 辰砂是什么| 上发条是什么意思| 基友是什么关系| poison是什么意思| 双肺呼吸音粗是什么意思| 吃什么治便秘最有效| 欠是什么意思| 一什么明珠| 阴道瘙痒用什么药| 日加个立念什么| 蝉联什么意思| 明天我要离开是什么歌| 宝宝流鼻涕吃什么药| 耳朵后面疼是什么原因| 顾客为什么购买| 腹部b超挂什么科| bp是什么职位| 胃ca是什么意思| 六月十四号是什么星座| 杨幂的公司叫什么名字| 男人前列腺在什么位置| d二聚体是查什么的| 五月一日是什么星座| 爱生气的人容易得什么病| 只吐不拉是什么原因| 什么是淋病| 你喜欢吃什么用英语怎么说| 抽筋吃什么药见效快| 三七是什么意思| 先算什么再算什么| 眼压高是什么原因造成的| mfr是什么意思| 蝉是什么意思| 干燥综合征挂什么科| 三叉神经痛有什么症状| 两肋插刀是什么意思| 脑供血不足是什么症状| sg什么意思| 交友是什么意思| 水痘长什么样子| 神经过敏是什么意思| 结婚下大雨是什么兆头| 半梦半醒是什么意思| 什么是陈述句| 胃窦糜烂是什么意思严重吗| 可以是什么意思| 梦见好多衣服是什么意思| 舌苔白厚腻吃什么药| 硬不起吃什么药| 冰乙酸是什么| 宫腔粘连带是什么意思| 生不如死什么意思| 满面红光是什么意思| 50分贝相当于什么声音| 喝什么茶可以降血脂| 女人没经验开什么店好| 情种是什么意思| 阳虚有什么症状| 吃什么排宿便清肠彻底| 女性下面流水什么原因| 现在是什么时辰| 合成碳硅石是什么| 掉眉毛是什么病| 牙刷属于什么垃圾| 潮湿的近义词是什么| 孕吐反应强烈说明什么| 子宫癌是什么症状| 福鼎白茶属于什么茶| 左侧头疼是什么原因引起的| 隐形眼镜什么牌子好| 做梦梦到很多蛇是什么意思| 什么药治肝最好最安全| 维生素e有什么功效| 泵头是什么| 毛囊炎用什么药膏| 慢脚是什么| 玻璃酸钠是什么| 为什么屎是臭的| 栩是什么意思| 单于是什么意思| 病毒性肠炎吃什么药| 杏花是什么季节开的| 蒙昧是什么意思| 安可是什么意思| 灬是什么意思| 天蝎座男生喜欢什么样的女生| 肚子里有虫子会有什么症状| 什么品种的西瓜最好吃| 1957属什么生肖| 腰椎间盘突出挂什么科| 鱼腥草破壁饮片有什么功效| 浓绿的什么| 高姿属于什么档次| 安瓶是什么| ich是什么意思| 女生为什么会喷水| 善良是什么| 百度Jump to content

高亚麟:刘星小雪小雨没发来贺电太不“孝顺”

From Wikipedia, the free encyclopedia
百度   第三季的比赛环节难度升级,新增了“诗词接龙”和“超级飞花令”两项全新玩法。

In computer programming, a static variable is a variable that has been allocated "statically", meaning that its lifetime (or "extent") is the entire run of the program. This is in contrast to shorter-lived automatic variables, whose storage is stack allocated and deallocated on the call stack; and in contrast to dynamically allocated objects, whose storage is allocated and deallocated in heap memory.

Variable lifetime is contrasted with scope (where a variable can be used): "global" and "local" refer to scope, not lifetime, but scope often implies lifetime. In many languages, global variables are always static, but in some languages they are dynamic, while local variables are generally automatic, but may be static.

In general, static memory allocation is the allocation of memory at compile time, before the associated program is executed, unlike dynamic memory allocation or automatic memory allocation where memory is allocated as required at run time.[1]

History

[edit]

Static variables date at least to ALGOL 60 (1960), where they are known as own variables:

A declaration may be marked with the additional declarator own. This has the following effect: upon a re-entry into the block, the values of own quantities will be unchanged from their values at the last exit, while the values of declared variables that are not marked with own is undefined.

—?Revised report on ALGOL 60, section "5. Declarations", p. 14

This definition is subtly different from a static variable: it only specifies behavior, and hence lifetime, not storage: an own variable can be allocated when a function is first called, for instance, rather than at program load time.

The use of the word static to refer to these variables dates at least to BCPL (1966), and has been popularized by the C programming language, which was heavily influenced by BCPL. The BCPL definition reads:

(1) Static data items:
Those data items whose extents lasts as long as the program execution time; such data items have manifest constant Lvalues. Every static data item must have been declared either in a function or routine definition, in a global declaration or as a label set by colon.

—?The BCPL Reference Manual, 7.2 Space Allocation and Extent of Data Items

Note that BCPL defined a "dynamic data item" for what is now called an automatic variable (local, stack-allocated), not for heap-allocated objects, which is the current use of the term dynamic allocation.

The static keyword is used in C and related languages both for static variables and other concepts.

Addressing

[edit]

The absolute address addressing mode can only be used with static variables, because those are the only kinds of variables whose location is known by the compiler at compile time. When the program (executable or library) is loaded into memory, static variables are stored in the data segment of the program's address space (if initialized), or the BSS segment (if uninitialized), and are stored in corresponding sections of object files prior to loading.

Scope

[edit]

In terms of scope and extent, static variables have extent the entire run of the program, but may have more limited scope. A basic distinction is between a static global variable, which has global scope and thus is in context throughout the program, and a static local variable, which has local scope. A static local variable is different from a local variable as a static local variable is initialized only once no matter how many times the function in which it resides is called and its value is retained and accessible through many calls to the function in which it is declared, e.g. to be used as a count variable. A static variable may also have module scope or some variant, such as internal linkage in C, which is a form of file scope or module scope.

Example

[edit]

An example of a static local variable in C:

#include <stdio.h>

void Func() {
  static int x = 0;
  // |x| is initialized only once across five calls of |Func| and the variable
  // will get incremented five times after these calls. The final value of |x|
  // will be 5.
  x++;
  printf("%d\n", x);  // outputs the value of |x|
}

int main() {
  Func();  // prints 1
  Func();  // prints 2
  Func();  // prints 3
  Func();  // prints 4
  Func();  // prints 5

  return 0;
}

Object-oriented programming

[edit]

In object-oriented programming, there is also the concept of a static member variable, which is a "class variable" of a statically defined class, i.e., a member variable of a given class which is shared across all instances (objects), and is accessible as a member variable of these objects. A class variable of a dynamically defined class, in languages where classes can be defined at run time, is allocated when the class is defined and is not static.

Object constants known at compile-time, such as string literals, are usually allocated statically. In object-oriented programming, the virtual method tables of classes are usually allocated statically. A statically defined value can also be global in its scope ensuring the same immutable value is used throughout a run for consistency.

See also

[edit]

Notes

[edit]
  1. ^ Jack Rons. "What is static memory allocation and dynamic memory allocation?". MeritHub [An Institute of Career Development]. Archived from the original on June 11, 2010. Retrieved 2025-08-06. The compiler allocates required memory space for a declared variable. By using the addressof operator, the reserved address is obtained and this address may be assigned to a pointer variable. Since most of the declared variables have static memory, this way of assigning pointer value to a pointer variable is known as static memory allocation. Memory is assigned during compilation time.

References

[edit]
上海玉佛寺求什么最灵验 刺猬喜欢吃什么食物 什么的蔷薇 fsh是什么 系统性红斑狼疮不能吃什么
澄字五行属什么 slc是什么意思 小孩过敏吃什么药 蔓越莓有什么功效和作用 狮子座是什么象
眼睛斜视是什么原因 嘴角上火是什么原因 吃完饭就想吐是什么原因 脉搏弱是什么原因 葡萄是什么季节的水果
怂人是什么意思 早上适合做什么运动 湿疹吃什么药 男性囊肿是什么引起的 七匹狼男装是什么档次
吃羊肉不能和什么一起吃hcv8jop2ns6r.cn 脸小适合什么发型yanzhenzixun.com 甲状腺肿是什么意思hcv9jop4ns5r.cn 流鼻血是什么原因hcv9jop5ns4r.cn aosc医学是什么意思hcv7jop6ns4r.cn
5.21什么星座hcv8jop8ns5r.cn 教师的职责是什么dajiketang.com 9月14号什么星座hcv8jop0ns0r.cn 早上起来口干口苦口臭是什么原因hcv8jop5ns8r.cn b型血和b型血生的孩子是什么血型kuyehao.com
眼白发红是什么原因hcv8jop0ns4r.cn 白脖什么意思hcv9jop1ns1r.cn 属蛇的人适合佩戴什么hcv9jop2ns0r.cn 减持是什么意思hcv7jop7ns0r.cn 2011属什么生肖hcv9jop2ns9r.cn
trans什么意思cj623037.com 为什么不能空腹喝豆浆hcv7jop9ns0r.cn 电磁炉什么牌子好jasonfriends.com 生理需要是什么意思hcv9jop7ns4r.cn 守字五行属什么hcv8jop7ns7r.cn
百度