静态变量 [英] static variable

查看:94
本文介绍了静态变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我定义静态变量时,为

静态变量分配的内存在哪里?

谢谢。


杰克

When I define a static variable, where is the memory allocated for the
static variable?
Thanks.

Jack

推荐答案

ju *** ***@gmail.com 写道:

当我定义一个静态变量时,在哪里分配给
$ b $的内存b静态变量?
When I define a static variable, where is the memory allocated for the
static variable?



位于实施定义位置的某处。


V

-

请在通过电子邮件回复时删除资金''A'

我没有回复最热门的回复,请不要问

Somewhere in an implementation-defined location.

V
--
Please remove capital ''A''s when replying by e-mail
I do not respond to top-posted replies, please don''t ask


ju******@gmail.com 写道:

>当我定义静态变量时,为
静态变量分配的内存在哪里?
>When I define a static variable, where is the memory allocated for the
static variable?



这是C和

C ++之间没有区别的区域之一。你在

comp.lang.c中提出相同问题时得到的答案仍然有效。

This is one of the areas were there is no difference between C and
C++. The answers you got when you asked the same question in
comp.lang.c are still valid.




Roberto Waltman写道:

Roberto Waltman wrote:
ju ****** @ gmail.com 写道:

当我定义一个静态变量时,为

静态变量分配的内存在哪里?
When I define a static variable, where is the memory allocated for the
static variable?



这是C和

C ++之间没有区别的区域之一。当你在

comp.lang.c中提出同样的问题时,你得到的答案仍然有效。


This is one of the areas were there is no difference between C and
C++. The answers you got when you asked the same question in
comp.lang.c are still valid.



我认为对于任何函数定义的静态变量,即它是全局变量的
a,它位于数据段中该程序。

函数中定义的静态变量怎么样?它是一个本地的

变量。它位于堆栈吗?


谢谢。

I think for a static variable defined out of any functions, i.e., it is
a global variable, it is located in the data segment of the program.
How about a static variable defined within a function? it is a local
variable. Is it located at the stack?

Thanks.


这篇关于静态变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆