当前位置:网站首页>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
边栏推荐
猜你喜欢

RL reinforcement learning summary (1)

雷克萨斯lm的安全性到底体现在哪里?一起来看看吧

ESP32 485 Illuminance

Using QR codes to solve fixed asset management challenges

MySQL Foundation (1) - Basic Cognition and Operation

span标签和p标签的区别

Excel Paint

MySQL基础(一)---基础认知及操作

Geek卸载工具

OFDM 十六讲 5 -Discrete Convolution, ISI and ICI on DMT/OFDM Systems
随机推荐
【练一下1】糖尿病遗传风险检测挑战赛 【讯飞开放平台】
【技能】长期更新
Analysis of Mvi Architecture
【Transfer】What is etcd
入口点注入
jvm three heap and stack
Flutter learning - the beginning
C#关于set()和get()方法的理解及使用
MySQL Foundation (1) - Basic Cognition and Operation
mutillidae download and installation
结构光三维重建(二)线结构光三维重建
【过一下8】全连接神经网络 视频 笔记
社区分享|腾讯海外游戏基于JumpServer构建游戏安全运营能力
LAB 信号量实现细节
Returned object not currently part of this pool
uva1325
【cesium】Load and locate 3D Tileset
【过一下 17】pytorch 改写 keras
Understanding and use of C# on set() and get() methods
ESP32 485光照度