What is useful about a reference-to-array parameter?

后端 未结 6 1477
野的像风
野的像风 2020-11-29 20:52

I recently found some code like this:

typedef int TenInts[10];
void foo(TenInts &arr);

What can you do in the body of foo()

6条回答
  •  误落风尘
    2020-11-29 21:10

    You can ensure that the function is only called on int arrays of size 10. That may be useful from a type-checking standpoint.

提交回复
热议问题