2017-10-10 76 views
2

我學習的模板,我覺得這個例子:如何識別部分模板特化

template <typename T, int size> 
void print(StaticArray<T, size> &array) 
{ 
    for (int count = 0; count < size; ++count) 
     std::cout << array[count] << ' '; 
} 


template <int size> 
void print(StaticArray<char, size> &array) 
{ 
    for (int count = 0; count < size; ++count) 
     std::cout << array[count]; 
} 

爲什麼第二print功能工作,即使它是有non-type參數size,爲什麼它是完整的模板專業化。

回答