通常,将数组形参直接定义为指针要比使用数组语法定义更好。
It is usually a good idea to define array parameters as Pointers, rather than using the array syntax.
有了得到允许的在一个数组中定义的形参,应用程序对参数处理代码的调用就可以像对一个静态方法的单个调用一样简单。
With the allowed parameters defined in an array, the call from the application program to the argument processing code can be kept as simple as a single call to a static method.
由于忽略了数组长度,形参定义中如果包含了数组长度则特别容易引起误解。
Because an array dimension is ignored, including a dimension in a parameter definition is particularly misleading.
因为数组不能复制,所以无法编写使用数组类型形参的函数。
Because we cannot copy an array, we cannot write a function that takes an array type parameter.
而在传递数组时,实参是指向数组第一个元素的指针,形参复制的是这个指针的值,而不是数组元素本身。
When we pass an array, the argument is a pointer to the first element in the array. That pointer value is copied; the array elements themselves are not copied.
实际上,形参是一个指针,指向数组的数组中的元素。
In fact, the parameter is a pointer to an element in an array of arrays.
形参指定激活特性数组。
虽然不能直接传递数组,但是函数的形参可以写成数组的形式。
Even though we cannot pass an array directly, we can write a function parameter that looks like an array.
在这种情况下,数组大小成为形参和实参类型的一部分。
In this case, the array size is part of the parameter and argument types.
如果形参是数组的引用,编译器不会将数组实参转化为指针,而是传递数组的引用本身。
If the parameter is a reference to the array, then the compiler does not convert an array argument into a pointer. Instead, a reference to the array itself is passed.
如果形参是数组的引用,编译器不会将数组实参转化为指针,而是传递数组的引用本身。
If the parameter is a reference to the array, then the compiler does not convert an array argument into a pointer. Instead, a reference to the array itself is passed.
应用推荐