当前位置:网站首页>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
边栏推荐
- Flex layout frog game clearance strategy
- 算法---一和零(Kotlin)
- 1.3 mysql batch insert data
- Day019 Method overriding and introduction of related classes
- Flutter学习2-dart学习
- [WeChat applet] WXML template syntax - conditional rendering
- How can Flutter parent and child components receive click events
- 2023 International Conference on Information and Communication Engineering (JCICE 2023)
- dedecms error The each() function is deprecated
- Error creating bean with name ‘configDataContextRefresher‘ defined in class path resource
猜你喜欢
【过一下9】卷积
2022 Hangzhou Electric Multi-School 1st Session 01
Using QR codes to solve fixed asset management challenges
The mall background management system based on Web design and implementation
Develop a highly fault-tolerant distributed system
开发一套高容错分布式系统
span标签和p标签的区别
Redis哨兵模式配置文件详解
jvm three heap and stack
[Student Graduation Project] Design and Implementation of the Website Based on the Web Student Information Management System (13 pages)
随机推荐
Qt produces 18 frames of Cupid to express his love, is it your Cupid!!!
"PHP8 Beginner's Guide" A brief introduction to PHP
Redis - 13. Development Specifications
HQL语句执行过程
Flutter学习5-集成-打包-发布
dedecms error The each() function is deprecated
2023年信息与通信工程国际会议(JCICE 2023)
位运算符与逻辑运算符的区别
Difference between for..in and for..of
【cesium】元素高亮显示
Structured light 3D reconstruction (1) Striped structured light 3D reconstruction
server disk array
【过一下4】09-10_经典网络解析
【过一下7】全连接神经网络视频第一节的笔记
【学生毕业设计】基于web学生信息管理系统网站的设计与实现(13个页面)
flex布局青蛙游戏通关攻略
Judgment statement _switch and case
uva1325
【无标题】
类的底层机制