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

后端 未结 6 1450
野的像风
野的像风 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:17

    One difference is that it's (supposed to be) impossible to pass a null reference. So in theory the function does not need to check if the parameter is null, whereas an int *arr parameter could be passed null.

提交回复
热议问题