#include<iostream>
using namespace std;
template <class T>
void printArray(const T *array, int count) {
for (int i=0; i< count; i++) {
cout << array[i] << " ";
}
cout << endl;
}
int main() {
const int A_COUNT = 5, B_COUNT = 6, C_COUNT = 7;
int a[A_COUNT] = {1, 2, 3, 4, 5};
double b[B_COUNT] = {1.1, 2.2, 3.3, 4.4, 5.5 ,6.6};
char c[C_COUNT] = "abcdef";
printArray(a, A_COUNT);
printArray(b, B_COUNT);
printArray(c, C_COUNT);
}
C++函数模板
最新推荐文章于 2023-05-22 19:44:26 发布