For example, an array named array: int len = sizeof (array)/sizeof (array [0]);
Len saved the array length of the array.
In addition, if the array is passed by reference, its length can be automatically obtained by parameter inference of the function template. The code is as follows:
//Print the elements of the array to the console continuously.
Template & lttypename T, int N>
Invalid print (t (&; arr[N])
{
for(int I = 0; I & ltn;; ++i){
cout & lt& ltarr[I];
}
}
//Example
int main()
{
int arrays[] = { 1,2,3,4,5 };
Print (array);
Returns 0;
}