template <typename Type, int N>
void Print_array(Type (&arr)[N]) {//数组的引用
for (int i = 0; i < N; i++) {
cout << arr[i] << " ";
}
cout << endl;
}
int main() {
int arr[] = { 1,2,3,4,5,6,7,8,9 };
double brr[] = { 1.2,2.3,3.4,4.5,5.6,6.7 };
Print_array(arr);
Print_array(brr);
}
数组的引用
最新推荐文章于 2024-08-16 21:01:11 发布