标签:image alt size_t template code 简单实现 mic print 函数
#include<iostream> using namespace std; template<typename T ,void (*f)(T& v)> void foreach(T arr[], unsigned size) { for (size_t i = 0; i < size; i++) { f(arr[i]); } } template<typename T> void print(T& v) { cout << " " << v << " "; } int main() { int arr[] = { 1,2,3,4,5,6,7,8 }; foreach<int, print<int> > (arr, 8); cin.get(); return 0; }
标签:image alt size_t template code 简单实现 mic print 函数
原文地址:https://www.cnblogs.com/linxuemufeng/p/12817777.html