正在加载图片...
第二节函数模板(教材①P316327) 例【62】定义一个函数模板swap(),使之能实现二个 整数的交换、二个双精度数的交换、二个点( point 类)的交换。( point类的定义在 hhpoint h中) #includesiostream.h> #include hhpoint h ∥ template< typename T>∥模板函数声明 template< class①>∥模板函数声明 void swap(t &a,T&b) fT temp temp=a; a=b; b=temp;第二节 函数模板(教材①P316-327) 例【6.2】定义一个函数模板swap( ),使之能实现二个 整数的交换、二个双精度数的交换、二个点(point 类)的交换。(point类的定义在hhpoint.h中) #include<iostream.h> #include"hhpoint.h" //template <typename T> //模板函数声明 template <class T> //模板函数声明 void swap(T &a,T &b) { T temp; temp=a;a=b;b=temp; }
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有