帮忙看一下那里有错误

来源:百度知道 编辑:UC知道 时间:2024/06/03 16:00:03
#inlude<iostream.h>
voin func(int &a,int&b,int&c)
{
a*=2;
b*=2;
c*=2;
}

int main()
int x=2,y=4,z=6;
func(x,y,z);
cout<<x<<y<<z;
return 0;
}

int main()
int x=2,y=4,z=6;
func(&x,&y,&z); /*这里传参数时要传地址.因为函数原形中的形参是指针*/
cout<<x<<y<<z;
return 0;
}

//可以了
#include<iostream.h>
void func(int &a,int &b,int &c)
{
a*=2;
b*=2;
c*=2;
}

int main()
{
int x=2,y=4,z=6;
func(x,y,z);
cout<<x<<y<<z;
return 0;
}

这么短的程序,错误还不少。。。

#include<iostream.h>
void func(int &a,int &b,int &c) //引用类型 直接改变地址所对应的值
{
a*=2;
b*=2;
c*=2;
}

int main()
{
int x=2,y=4,z=6;
func(x,y,z);
cout<<x<<y<<z;
return 0;
}