我正在学习模板,在这里我找到了这个例子:
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,以及为什么它是完全模板专业化。
https://stackoverflow.com/questions/46658927
复制相似问题