int &arr[10] //error 将arr声明成了引用的数组
int (&arr)10 //right,ref a 整形10维数组
template<typename T, unsigned size>
constexpr unsigned getSize(const T(&)[size])
{
return size;
}
int main()
{
char s[] = { "sss" };
std::cout << getSize(s) << std::endl;
char c[] = "s";
std::cout << getSize(c) << std::endl;
// the output is 2, as '\0' is added at the end of the array
std::cin.get();
return 0;
}
//(const T(&)[size]) 引用一个数组(&)【size】