本文介绍了静态变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 函数内部的静态变量存储在哪里? 它在内存中的位置?就像Global进入RAM,局部变量继续 Stack ...但静态变量如何在内存中发生? 解决方案 它这是一个实施问题。如果详细信息对您的 应用程序很重要,请参阅编译器的文档。 - Ian Collins。 在随机存取存储器或RAM中。 (或者,如果它是常量,可能会将 放入只读存储器或ROM中)。 这取决于实施。它有所不同。 假设你的意思是带有外部链接的文件范围对象,是的,他们是存储在RAM中的(除非他们是const,在这种情况下他们可能会进入 ROM)。 假设你的意思是自动对象,它们被存储在RAM中,除非 他们是const,在这种情况下他们可能会进入ROM。它们可能是某种堆栈结构中的,或者它们可能没有。 这取决于实现。 它进入RAM(或者,如果它是const,它可能会进入ROM)。精确的 细节取决于实施。 - Richard Heathfield " Usenet是一个奇怪的地方 - dmr 29/7/1999 http://www.cpax.org.uk 电子邮件:rjh在上述域名中, - www。 这是一个实施问题。如果详细信息对您的 应用程序很重要,请参阅编译器的文档。 - Ian Collins。 where does a static variable inside a function get stored?? where doesit go in memory?? like Global goes in RAM, Local variable goes onStack... but how does static variable takes place in memory?? 解决方案It''s an implementation issue. If the detail is important for yourapplication, consult your compiler''s documentation.--Ian Collins.In random access memory, or "RAM" (or, if it''s const, it might get putinto read-only memory, or "ROM").That''s up to the implementation. It varies.Assuming you mean file scope objects with external linkage, yes, they''restored in RAM (unless they''re const, in which case they might go intoROM).Assuming you mean automatic objects, they''re stored in RAM, unlessthey''re const, in which case they might go into ROM. They might beincorporated into some kind of a stack structure, or they might not.It''s up to the implementation.It goes into RAM (or, if it''s const, it might go into ROM). The precisedetails depend on the implementation.--Richard Heathfield"Usenet is a strange place" - dmr 29/7/1999 http://www.cpax.org.ukemail: rjh at the above domain, - www.It''s an implementation issue. If the detail is important for yourapplication, consult your compiler''s documentation.--Ian Collins. 这篇关于静态变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!