---
title: "函数调用时的三种参数传递方式"
author: "hello_wangfeng"
date: "2012-11-10T23:30:15Z"
tags: ["C++", "参数传递"]
categories: ["编程语言"]
slug: "untitled"
draft: false
lastmod: "2012-11-12T21:27:13Z"
id: 1722363
url: "https://hello-wangfeng.iteye.com/blog/1722363"
---

\[size=medium]今天学习《从新手到高手C++全部精华教程》，http://www.iteye.com/topic/1126275 知道了函数调用的三种参数传递方式： 第一种：传值\[/size] \[code="C++"] #include using namespace std; void swap(int a, int b){ int c; cout&lt;&lt;"swap交换前"&lt;&lt;"a:"&lt; using namespace std; void swap(int \*a, int \*b){ //\*a,\*b是说形参是指针变量，用于接收实参的地址 int c; cout&lt;&lt;"swap交换前"&lt;&lt;"\*a:"&lt;&lt;\*a&lt; using namespace std; void swap(int &a, int &b){ //&a,&b是说形参是引用变量，用于接收实参 int c; cout&lt;&lt;"swap交换前"&lt;&lt;"a:"&lt;