关于形参和实参的理解问题
“在参数传递时,实参和形参在数量上,类型上,顺序上应严格一致”这句话怎样理解,是什么意思
“在参数传递时,实参和形参在数量上,类型上,顺序上应严格一致”这句话怎样理解,是什么意思
2018-02-26
//比如说
int fun(int i_int, double d_double){.....}
int main()
{
int i_int1 = 10;
double d_double1 = 99.9;
//类型,顺序上一致
fun(i_int1, d_double1); //即,int i_int = i_int1; double d_double = d_double1;
//类型上不一致
fun(i_int1, i_int1); //即,int i_int = i_int1; double d_double = i_int1;
fun(d_double1, d_double1);//即,int i_int =d_double1; double d_double = d_double1;
//这都是错误的
//顺序上不一致
fun(d_double1,i_int); //即,int i_int = d_double1; double d_double = i_int1;
//这也是错误的
举报