关键词搜索

源码搜索 ×
×

浅谈变量的存储位置

发布2014-10-24浏览7509次

详情内容

  1. #include <iostream>
  2. using namespace std;
  3. static int a = 10;
  4. extern int b = 20; // 其实extern 在此处是多余的
  5. int c = 30;
  6. int main()
  7. {
  8. cout << &a << endl;
  9. cout << &b << endl;
  10. cout << &c << endl;
  11. static int d = 40;
  12. cout << &d << endl;
  13. int e = 50;
  14. cout << &e << endl;
  15. //extern int g = 20; // error
  16. //cout << &g << endl;
  17. return 0;
  18. }
00476DC0
00476DC4
00476DC8
00476DCC

0013FF7C

        可见: 全局变量, 全局静态变量, 局部静态变量都放在一个区, 就叫做“静态数据库”, static data area. --- 《C++编程思想》

      

相关技术文章

点击QQ咨询
开通会员
返回顶部
×
微信扫码支付
微信扫码支付
确定支付下载
请使用微信描二维码支付
×

提示信息

×

选择支付方式

  • 微信支付
  • 支付宝付款
确定支付下载