The difference between int a[5] and int (&a)[5] in template parameter deduction

与世无争的帅哥 提交于 2019-12-05 02:03:09
Mark Ransom

The compiler silently changes the type of function argument int a[N] to int *a and thus loses the size of the array. int(&a)[5] is truly a reference to an array of size 5, and cannot be passed an array of any other size.

I think its the difference between a reference and a pointer.

arrfun_a passes a pointer to int.

arrfun_b passes a reference to an array of ints.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!