注册 登录
编程论坛 C++教室

引用做参数的函数说明和调用的格式是什么

卡卡罗特wang 发布于 2012-04-16 17:52, 338 次点击
引用做参数的函数说明和调用的格式是什么
3 回复
#2
寒风中的细雨2012-04-17 09:15
int max(int *array, int size, int &retvalue);


int a[] = {1, 2, 3, 4, 5};
int ret;
max(a, 5,  ret);
#3
ab10349827492012-04-17 12:03
//下面举个例子,是求最大值的,
#include<iostream>
using namespace std;
int main(void)
{
    void max(int &,int &);//声名函数参数为引用的函数;
    int c=5,d=10;
    max(c,d);
    cout<<"最大值为:"<<c<<endl;
    return 0;

}
void max(int &a,int &b)
{   
    if(a<b)
        a=b;

}
#4
卡卡罗特wang2012-04-17 16:01
回复 3楼 ab1034982749
索嘎,原来还可以在函数体内声明函数啊,我一直以为只能在外面……
1