阿杰 发表于 2009-8-9 02:11:21

【原创】函数模块

<font face="Verdana">//函数模块<br/>//阿杰:2009年8月9日2:10:18<br/>template &lt;class t&gt;<br/>swap (t &amp;a,t &amp;b) //这交换的变量可以是任何类型<br/>{<br/>&nbsp;t c;<br/>&nbsp;c=a;<br/>&nbsp;a=b;<br/>&nbsp;b=c;<br/>}<br/>int main(int argc, char* argv[])<br/>{<br/>&nbsp;int a=10,b=11;<br/>&nbsp;<br/>&nbsp;printf("a=%d,b=%d\n",a,b);<br/>&nbsp;swap(a,b);<br/>&nbsp;printf("a=%d,b=%d\n",a,b);<br/>&nbsp;return 0;<br/>}</font>
页: [1]
查看完整版本: 【原创】函数模块