当前位置:网站首页>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哨兵模式配置文件详解
- Flutter学习2-dart学习
- "PHP8 Beginner's Guide" A brief introduction to PHP
- 【解码工具】Bitcoin的一些在线工具
- span标签和p标签的区别
- Community Sharing|Tencent Overseas Games builds game security operation capabilities based on JumpServer
- 逆向理论知识4
- What field type of MySQL database table has the largest storage length?
- 【过一下11】随机森林和特征工程
- redis复制机制
猜你喜欢
随机推荐
Geek卸载工具
【无标题】
u-boot in u-boot, dm-pre-reloc
Flutter学习三-Flutter基本结构和原理
逆向理论知识4
Flutter TapGestureRecognizer 如何工作
【记一下1】2022年6月29日 哥和弟 双重痛苦
雷克萨斯lm的安全性到底体现在哪里?一起来看看吧
重新审视分布式系统:永远不会有完美的一致性方案……
[cesium] element highlighting
How does the Flutter TapGestureRecognizer work
Develop a highly fault-tolerant distributed system
Using QR codes to solve fixed asset management challenges
Distributed systems revisited: there will never be a perfect consistency scheme...
LeetCode: 1403. Minimum subsequence in non-increasing order [greedy]
Redis - 13、开发规范
2022 Hangzhou Electric Multi-School 1st Session 01
二叉树基本性质+oj题解析
entry point injection
Returned object not currently part of this pool




![[Study Notes Dish Dog Learning C] Classic Written Exam Questions of Dynamic Memory Management](/img/0b/f7d9205c616f7785519cf94853d37d.png)




