你好,我是普林斯特。

计算机的所有东西都是人做出来的,别人能想得出来的,我也一定能想得出来,在计算机里头,没有任何黑魔法,所有的东西,只不过是我现在不知道而已,总有一天,我会把所有的细节,所有的内部的东西全都搞明白的。       ----翁恺老师

愿你成为部落最强大的战士…                                                  

Part-Eight 模板与群体数据的组织

1.方法模板

#include<iostream>
using namespace std;
template<typename T>
void outputArray(const T*array,int count)
{
    for(int i=0;i<count;i++)
    {
        cout<<array[i]<<" "; 
    }
    cout<<endl;
}
int main()
{
    const int A_COUNT=8,B_COUNT=8,C_COUNT=20;
    int a[A_COUNT]={1,2,3,4,5,6,7,8};
    double b[B_COUNT]={1.1,2.2,3.3,4.4,5.5,6.6,7.7,8.8};
    char c[C_COUNT]="Welcome to see you!";
    outputArray(a,A_COUNT);
    outputArray(b,B_COUNT);
    outputArray(c,C_COUNT); 
    return 0;
}

 

2.

3.

4.

5.

6.

7.

8.

9.

10.

11.

12.

 

posted @ 2019-04-16 00:24  珞珈山  阅读(164)  评论(0编辑  收藏  举报