Hello everyone,
In the following code, how GetArrayLength(arr1) is matched to template function size_t GetArrayLength(const T(&arr)[size])? My confusion is how arr1 is matched to const T(&arr)[size]? I have tried to change const T(&arr)[size] to const T(arr)[size]) but it does not work.
Code:template<size_t size, typename T>
size_t GetArrayLength(const T(&arr)[size])
{
return size;
}
int main()
{
char arr1[] = "Hello World";
std::cout << GetArrayLength(arr1) << std::endl;
return 0;
}
thanks in advance,
George