C++函数模板
#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);
}
    作者:
tongqingliu
出处: http://www.cnblogs.com/liutongqing/
本文版权归作者和博客园共有,欢迎转载、交流,但未经作者同意必须保留此段声明,且在文章明显位置给出原文链接。
如果觉得本文对您有益,欢迎点赞、欢迎打赏。
 
 
出处: http://www.cnblogs.com/liutongqing/
本文版权归作者和博客园共有,欢迎转载、交流,但未经作者同意必须保留此段声明,且在文章明显位置给出原文链接。
如果觉得本文对您有益,欢迎点赞、欢迎打赏。
 
 
posted on 2020-08-15 14:27 tongqingliu 阅读(119) 评论(0) 收藏 举报
 
                
            
         
         浙公网安备 33010602011771号
浙公网安备 33010602011771号