当前位置:网站首页>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
边栏推荐
猜你喜欢
随机推荐
redis事务
Excel Paint
A blog clears the Redis technology stack
number_gets the specified number of decimals
OFDM 十六讲 5 -Discrete Convolution, ISI and ICI on DMT/OFDM Systems
redis复制机制
Flutter学习-开篇
淘宝账号如何快速提升到更高等级
【转】什么是etcd
The mall background management system based on Web design and implementation
【过一下4】09-10_经典网络解析
【过一下14】自习室的一天
u-boot调试定位手段
Requests the library deployment and common function
Structured Light 3D Reconstruction (2) Line Structured Light 3D Reconstruction
2022杭电多校第一场01
开发一套高容错分布式系统
分布式和集群
延迟加载js方式async与defer区别
Geek卸载工具








