C++快速入门 第十二讲:传值、传址和传引用
实例1:值传递
1 #include<iostream> 2 3 void changeAge(int age,int newAge); 4 int main() 5 15 16 void changeAge(int age,int newAge)//再定义一个age,占另一处地址 17绕开“值传递”问题的第一种方法是向函数传递变量的地址取代他的值。
实例2:指针地址传递
1 #include<iostream> 2 3 void changeAge(int *age,int newAge); 4 int main() 5 15 16 void changeAge(int *age,int newAge)//再定义一个age,占另一处地址 17实例3:两值互换
1 #include<iostream> 2 3 void swap(int *x,int *y); 4 int main() 5 16 17 void swap(int *x,int *y) 18实例4:两值互换2
1 #include<iostream> 2 3 void swap(int *x,int *y); 4 int main() 5 16 17 void swap(int *x,int *y) 18实例5:不用指针的两值交换
1 #include <iostream> 2 3 void swap(int &x,int &y); 4 5 int main() 6 16 17 void swap(int &x,int &y) 18C/C++
spc文件怎么看,spc文件用什么打开?
0文件怎么看,0文件用什么打开?
sparseimage文件怎么看,sparseimage文件用什么打开?
sp文件怎么看,sp文件用什么打开?
dv文件怎么看,dv文件用什么打开?
soundpack文件怎么看,soundpack文件用什么打开?
dus文件怎么看,dus文件用什么打开?
dtw文件怎么看,dtw文件用什么打开?
spdf文件怎么看,spdf文件用什么打开?
0文件怎么看,0文件用什么打开?