当前位置:网站首页>Address assignment of global variables, local variables, static variables and constants
Address assignment of global variables, local variables, static variables and constants
2022-07-18 16:02:00 【anthony-36】
#include <iostream>
using namespace std;
// Global variables
int g_a = 10;
int g_b = 10;
const int c_g_a = 10;
const int c_g_b = 10;
int main()
{
// Global area
// Global variables 、 Static variables 、 Constant
// Create ordinary local variables
int a = 10;
int b = 10;
cout << " local variable a The address for :" << (int)&a << endl;
cout << " local variable b The address for :" << (int)&b << endl;
cout << " Global variables g_a The address for :" << (int)&g_a << endl;
cout << " Global variables g_b The address for :" << (int)&g_b << endl;
// Static variables
static int s_a = 10;
static int s_b = 10;
cout << " Static variables s_a The address for :" << (int)&s_a << endl;
cout << " Static variables s_b The address for :" << (int)&s_b << endl;
// Constant
// String constant —— String induced
cout << " The address of the string constant is :" << (int)&"hello world" << endl;
//const Decorated variable
//const Decorated global variables ,const Modified local variables
cout << " Global variables c_g_a The address for :" << (int)&c_g_a << endl;
cout << " Global variables c_g_b The address for :" << (int)&c_g_b << endl;
const int c_l_a = 10;
const int c_l_b = 10;
cout << " local variable c_l_a The address for :" << (int)&c_l_a << endl;
cout << " local variable c_l_b The address for :" << (int)&c_l_b << endl;
return 0;
}

Here you can see that local variables and local constants are in the same area , But not in the global area .
And global variables 、 Static variables 、 Both global constants and string variables are in the global area .
边栏推荐
- Uniapp code scanning native plug-ins (Google mlkit, zxing; support scanning multiple codes at the same time)
- Apache stress testing tool AB, with post parameter and token request
- [training Day2] cinema ticket [combinatorics] [Cartland number]
- ELK集群部署(五)之部署FileBeat
- Use tcpkill to block packets of the specified TCP connection
- 使用 tcpkill 阻断指定 TCP 连接的数据包
- [training Day2] torch bearer [violence] [DFS]
- What is the composition of CPU
- 使用arcpy遇到的那些坑(三)
- Assist developers to comprehensively interpret APIs IX test cases
猜你喜欢

可再生金融ReFi:提供对地球有利的技术和金融系统

9. 说说hashCode() 和 equals() 之间的关系?

The solution to the slow download speed of vs2019 recently

7.13学习记录

关于唐医生的一切:真实的中国人工心脏是什么样?

C language under custom type (enumeration, Union)

使用arcpy遇到的那些坑(三)

Chapter3美国大选金献项目数据分析

Do you know the meaning of call concurrency in okcc?

465 sword finger offer (53-i, 53-ii, 04, 50)
随机推荐
The pits encountered using arcpy (3)
关于唐医生的一切:真实的中国人工心脏是什么样?
Big guy said * computing talk Club | Sanxingdui fantasy trip: an experience that only cloud computing can bring
AutoJs学习-应用列表
Leetcode question brushing record 17
CF609A USB Flash Drives
再次了解max_allowed_packet
7.14二分,LCA,差分,思维构造
Web page making (II)
apache 压力测试工具 ab ,带post参数,token请求
軟件測試面試:請說一下你工作中發現的最有價值的bug?
分享一个超好用的 轮询 + 定时器管理器
Take Celsius as a negative textbook to teach you how to judge the quality of products and avoid investment risks
启用远程 rsyslog 日志服务
Runtime data area & method area (permanent generation / meta space) & stack frame
玩转“私域电商”,链动2+1模式值得企业深入了解吗?
##负载均衡LVS集群详解##
Chapter3美国大选金献项目数据分析
What is EOC
图解数组计算模块NumPy下(三角函数、四舍五入函数(around)、取整、将弧度转化为角度、统计分析函数、中位数、数组的排序、argsort()、lexsort())