C++中模板函数的巧用
//模板函数可以吧类型当作参数typedef struct{char a[2];int b;}PARAM;template<class T>void Transfer(T *t, char *buffer) //模板函数{*t = *(reinterpret_cast<T *>(buffer));}www.zzzyk.comvoid main(){char *p;PARAM param1, param2;param1.a[0] = 'a';param1.a[1] = 'b';param1.b = 119;p = (char*)(¶m1);Transfer(¶m2,p);}
补充:软件开发 , C++ ,