首页 > 代码库 > template stuff in C++

template stuff in C++

1. Template function 

template <class T> // a template prefixT func(T a, T b, T c){ // return value is T type, 3 T-typed formal parameters   return a + b + c;}

We could also specify different types here: 

template <class T1, class T2, class T3>T1 func(const T1& a, const T2& b, const T3& c){ // passing 3 different types of formal parameter   return a + b + c; // return value is T1-typed}

 

template stuff in C++