#include<iostream>
using namespace std;
int main()
{
double score[]{11, 22, 33, 44, 55, 66};
double* ptr_score = score;
cout << sizeof(score) << "\t" << sizeof(ptr_score) << endl;
/*int num = 108;
int& rel_num = num;
rel_num = 118;
cout << &num << "\t" << &rel_num << endl;*/
}
数组名就是数组的首地址(不完全正确)
使用sizeof可以看到数组名的含义,比如这里输出是6*8=48
指针为四个字节,所以输出4
修改变量的两种方法:
1.通过变量
2.通过指针
#include<iostream>
using namespace std;
int main()
{
int a = 10;
int* b;
b = &a;
*b = 20;
cout << a << endl;
}
这是通过指针修改变量值。