c数组作为函数参数返回数组
Arrays in Delphi allow us to refer to a series of variables by the same name and to use a number (an index) to tell them apart.
Delphi中的数组允许我们使用相同的名称引用一系列变量,并使用数字(索引)来区分它们。
Here's an example integer array that can hold up to 7 (integer) values. Note: this is a fixed-size static Delphi array declaration.
这是一个示例数组 ,最多可容纳7个(整数)值。 注意:这是一个固定大小的静态Delphi数组声明。
数组作为函数返回类型 ( Arrays as Function Return Types )
In Delphi, functions are routines that return a value.
在Delphi中, 函数是返回值的例程。
When you want a function to return an array type variable, you might be tempted to use the next declaration:
当您希望函数返回数组类型变量时,您可能会想使用下一个声明:
When you try to compile this code, you'll get the next compile-time error: [Pascal Error] E2029 Identifier expected but 'ARRAY' found.
当您尝试编译此代码时,您将得到下一个编译时错误: [Pascal错误] E2029预期的标识符,但找到了'ARRAY' 。
Obviously, when you declare functions that will return array value, you cannot include index type specifiers return declaration.
显然,声明要返回数组值的函数时,不能包含索引类型说明符返回声明。
In order to allow a function to return an array value, you first need to create a custom array type, then use it as a return function type:
为了允许函数返回数组值 ,您首先需要创建一个自定义数组类型,然后将其用作返回函数类型:
数组作为方法/例程属性 ( Arrays as Method/Routine Properties )
Similar to using arrays as function return types, when you declare routines that take array parameters, you cannot include index type specifiers in the parameter declarations.
与使用数组作为函数返回类型相似,当您声明采用数组参数的例程时,不能在参数声明中包括索引类型说明符。
翻译自: https://www.thoughtco.com/array-as-a-function-return-type-1057837
c数组作为函数参数返回数组