数组的引用 C++

来源:互联网 发布:淘宝商城电脑版 编辑:程序博客网 时间:2024/06/02 02:55
char  & x[5] // declare x as array 5 of reference to char (not valid C++!)char (&x)[5] // declare x as reference to array 5 of char

Caution: The first version is not valid C++, though, since you cannot have arrays of references. This is merely an explanation of the declaration syntax. If you want to take an array by reference, then you MUST specify the dimension. e.g.

You're allowed to wrap the type identifier in arbitray levels of parentheses if you like, so you can also saychar &(x)[5] (first case) or char (((&x)))[5] (second case).