//模板函數可以吧類型當作參數 typedef struct { char a[2]; int b; }PARAM; template<class T> void Transfer(T *t, char *buffer) //模板函數 { *t = *(reinterpret_cast<T *>(buffer)); } www.2cto.com void main() { char *p; PARAM param1, param2; param1.a[0] = 'a'; param1.a[1] = 'b'; param1.b = 119; p = (char*)(¶m1); Transfer(¶m2,p); }