c数组作为函数参数返回数组_数组作为函数的返回类型和方法参数

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数组作为函数参数返回数组

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值