p*********9 发帖数: 277 | 1 【 以下文字转载自 Programming 讨论区 】
发信人: powerplay09 (Roy), 信区: Programming
标 题: 问个static的问题
发信站: BBS 未名空间站 (Thu Mar 10 21:13:09 2011, 美东)
c和c++中的static有什么区别阿?
谢谢. | g*********e 发帖数: 14401 | 2 is it that they are stored in slightly different locations in memory? not
exactly sure | c***2 发帖数: 838 | 3 In C++, static also means there is only one instance of that (variable/
method).
in both c and C++
1) scope: local to this file
2) retains value in function calls
3) memory is allocated at compile time on data section instead of runtime on
stack |
|