当前位置:网站首页>02.01-----参数的引用的作用“ & ”
02.01-----参数的引用的作用“ & ”
2022-08-05 05:13:00 【长路漫漫 大佬为伴】
参数的引用的作用“ & ”
对参数的修改需要带回来的,就要使用引用符号 “&”
无参数的引用“ & ”
#include <iostream>
using namespace std;
void test(int x){
x=1024;
printf("test函数内部 x=%d\n",x);
}
int main(){
int x=1;
printf("调用test前 x=%d\n",x);
test(x);
printf("调用test后 x=%d\n",x);
}
调用test前 x=1
test函数内部 x=1024
调用test后 x=1
使用参数的引用“ & ”
#include <iostream>
using namespace std;
void test(int &x){
x=1024;
printf("test函数内部 x=%d\n",x);
}
int main(){
int x=1;
printf("调用test前 x=%d\n",x);
test(x);
printf("调用test后 x=%d\n",x);
}
调用test前 x=1
test函数内部 x=1024
调用test后 x=1024
边栏推荐
猜你喜欢
随机推荐
Flutter learning - the beginning
LAB Semaphore Implementation Details
Error creating bean with name 'configDataContextRefresher' defined in class path resource
phone call function
How to quickly upgrade your Taobao account to a higher level
【过一下10】sklearn使用记录
Excel画图
入口点注入
UVA10827
[cesium] 3D Tileset model is loaded and associated with the model tree
number_gets the specified number of decimals
【Transfer】What is etcd
【过一下11】随机森林和特征工程
uva1325
How can Flutter parent and child components receive click events
"PHP8 Beginner's Guide" A brief introduction to PHP
MySQL Foundation (1) - Basic Cognition and Operation
2023 International Conference on Information and Communication Engineering (JCICE 2023)
Structured light 3D reconstruction (1) Striped structured light 3D reconstruction
Difference between for..in and for..of









