类模板43 函数模板 template<class c> void square(c num, c *result)t ★resu]t=num★num; 类模板 template<class T> class Array i public int getlengtho[return length i T& operator [](int i)return array[i]i y Array (int l)i length 1 array new T[length]i array o delete [ array; y private int length f*array; 12}; 北大青鸟12 类模板 4-3 template<class C> void square(C num, C *result){ *result = num * num; } template<class T> class Array { public: int getlength() {return length;} T & operator[](int i) {return array[i];} Array(int l) { length = l; array = new T[length]; } ~Array() {delete [] array;} private: int length; T *array; }; 函数模板 类模板