﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>C++博客-Achiber-随笔分类-C++learning</title><link>http://www.cppblog.com/Achiber/category/20097.html</link><description>代码改变世界，让我们一起默默的努力！</description><language>zh-cn</language><lastBuildDate>Mon, 26 Nov 2012 06:08:07 GMT</lastBuildDate><pubDate>Mon, 26 Nov 2012 06:08:07 GMT</pubDate><ttl>60</ttl><item><title>模板类</title><link>http://www.cppblog.com/Achiber/archive/2012/11/23/195616.html</link><dc:creator>王文豪</dc:creator><author>王文豪</author><pubDate>Fri, 23 Nov 2012 14:43:00 GMT</pubDate><guid>http://www.cppblog.com/Achiber/archive/2012/11/23/195616.html</guid><wfw:comment>http://www.cppblog.com/Achiber/comments/195616.html</wfw:comment><comments>http://www.cppblog.com/Achiber/archive/2012/11/23/195616.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/Achiber/comments/commentRss/195616.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/Achiber/services/trackbacks/195616.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->#include&nbsp;&lt;iostream&gt;#include&nbsp;&lt;stdio.h&gt;#include&nbsp;&lt;iostream.h&gt;template&nb...&nbsp;&nbsp;<a href='http://www.cppblog.com/Achiber/archive/2012/11/23/195616.html'>阅读全文</a><img src ="http://www.cppblog.com/Achiber/aggbug/195616.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/Achiber/" target="_blank">王文豪</a> 2012-11-23 22:43 <a href="http://www.cppblog.com/Achiber/archive/2012/11/23/195616.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>模版函数的重载</title><link>http://www.cppblog.com/Achiber/archive/2012/11/23/195615.html</link><dc:creator>王文豪</dc:creator><author>王文豪</author><pubDate>Fri, 23 Nov 2012 14:33:00 GMT</pubDate><guid>http://www.cppblog.com/Achiber/archive/2012/11/23/195615.html</guid><wfw:comment>http://www.cppblog.com/Achiber/comments/195615.html</wfw:comment><comments>http://www.cppblog.com/Achiber/archive/2012/11/23/195615.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/Achiber/comments/commentRss/195615.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/Achiber/services/trackbacks/195615.html</trackback:ping><description><![CDATA[<div style="border-bottom: #cccccc 1px solid; border-left: #cccccc 1px solid; padding-bottom: 4px; background-color: #eeeeee; padding-left: 4px; width: 98%; padding-right: 5px; font-size: 13px; word-break: break-all; border-top: #cccccc 1px solid; border-right: #cccccc 1px solid; padding-top: 4px"><img id="Code_Closed_Image_223251" onclick="this.style.display='none'; Code_Closed_Text_223251.style.display='none'; Code_Open_Image_223251.style.display='inline'; Code_Open_Text_223251.style.display='inline';" align="top" src="http://www.cppblog.com/images/OutliningIndicators/ContractedBlock.gif" width="11" height="16"><img style="display: none" id="Code_Open_Image_223251" onclick="this.style.display='none'; Code_Open_Text_223251.style.display='none'; Code_Closed_Image_223251.style.display='inline'; Code_Closed_Text_223251.style.display='inline';" align="top" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockStart.gif" width="11" height="16"><span style="border-bottom: #808080 1px solid; border-left: #808080 1px solid; background-color: #ffffff; border-top: #808080 1px solid; border-right: #808080 1px solid" id="Code_Closed_Text_223251"></span><span style="display: none" id="Code_Open_Text_223251"><br /><!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />--><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/None.gif"  alt="" /><span style="color: #000000">#include&nbsp;</span><span style="color: #000000">&lt;</span><span style="color: #000000">iostream</span><span style="color: #000000">&gt;</span><span style="color: #000000"><br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/None.gif"  alt="" /></span><span style="color: #0000ff">using</span><span style="color: #000000">&nbsp;</span><span style="color: #0000ff">namespace</span><span style="color: #000000">&nbsp;std;<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/None.gif"  alt="" /><br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/None.gif"  alt="" />template&nbsp;</span><span style="color: #000000">&lt;</span><span style="color: #000000">typename&nbsp;T1&nbsp;,&nbsp;typename&nbsp;T2</span><span style="color: #000000">&gt;</span><span style="color: #000000"><br /><img id="Codehighlighter1_96_188_Open_Image" onclick="this.style.display='none'; Codehighlighter1_96_188_Open_Text.style.display='none'; Codehighlighter1_96_188_Closed_Image.style.display='inline'; Codehighlighter1_96_188_Closed_Text.style.display='inline';" align="top" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockStart.gif"><img style="display: none" id="Codehighlighter1_96_188_Closed_Image" onclick="this.style.display='none'; Codehighlighter1_96_188_Closed_Text.style.display='none'; Codehighlighter1_96_188_Open_Image.style.display='inline'; Codehighlighter1_96_188_Open_Text.style.display='inline';" align="top" src="http://www.cppblog.com/images/OutliningIndicators/ContractedBlock.gif">T2&nbsp;fun(T1&nbsp;x,T2&nbsp;y)</span><span style="border-bottom: #808080 1px solid; border-left: #808080 1px solid; background-color: #ffffff; display: none; border-top: #808080 1px solid; border-right: #808080 1px solid" id="Codehighlighter1_96_188_Closed_Text"><img src="http://www.cppblog.com/Images/dot.gif"  alt="" /></span><span id="Codehighlighter1_96_188_Open_Text"><span style="color: #000000">{<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;cout</span><span style="color: #000000">&lt;&lt;</span><span style="color: #000000">"</span><span style="color: #000000">调用了两个个参数的&nbsp;fun&nbsp;函数</span><span style="color: #000000">"</span><span style="color: #000000">&lt;&lt;</span><span style="color: #000000">endl;<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;T2&nbsp;tmp&nbsp;</span><span style="color: #000000">=</span><span style="color: #000000">&nbsp;x&nbsp;</span><span style="color: #000000">*</span><span style="color: #000000">x&nbsp;</span><span style="color: #000000">+</span><span style="color: #000000">&nbsp;y&nbsp;</span><span style="color: #000000">*</span><span style="color: #000000">&nbsp;y&nbsp;</span><span style="color: #000000">+</span><span style="color: #000000">&nbsp;x&nbsp;</span><span style="color: #000000">*</span><span style="color: #000000">&nbsp;y;<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">return</span><span style="color: #000000">&nbsp;tmp;<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockEnd.gif"  alt="" />}</span></span><span style="color: #000000"><br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/None.gif"  alt="" /><br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/None.gif"  alt="" />template&nbsp;</span><span style="color: #000000">&lt;</span><span style="color: #000000">typename&nbsp;T</span><span style="color: #000000">&gt;</span><span style="color: #000000"><br /><img id="Codehighlighter1_235_349_Open_Image" onclick="this.style.display='none'; Codehighlighter1_235_349_Open_Text.style.display='none'; Codehighlighter1_235_349_Closed_Image.style.display='inline'; Codehighlighter1_235_349_Closed_Text.style.display='inline';" align="top" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockStart.gif"><img style="display: none" id="Codehighlighter1_235_349_Closed_Image" onclick="this.style.display='none'; Codehighlighter1_235_349_Closed_Text.style.display='none'; Codehighlighter1_235_349_Open_Image.style.display='inline'; Codehighlighter1_235_349_Open_Text.style.display='inline';" align="top" src="http://www.cppblog.com/images/OutliningIndicators/ContractedBlock.gif">T&nbsp;fun(T&nbsp;x&nbsp;,&nbsp;T&nbsp;y&nbsp;,&nbsp;T&nbsp;z)</span><span style="border-bottom: #808080 1px solid; border-left: #808080 1px solid; background-color: #ffffff; display: none; border-top: #808080 1px solid; border-right: #808080 1px solid" id="Codehighlighter1_235_349_Closed_Text"><img src="http://www.cppblog.com/Images/dot.gif"  alt="" /></span><span id="Codehighlighter1_235_349_Open_Text"><span style="color: #000000">{&nbsp;&nbsp;</span><span style="color: #008000">//</span><span style="color: #008000">模版函数的重载</span><span style="color: #008000"><br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" /></span><span style="color: #000000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;cout</span><span style="color: #000000">&lt;&lt;</span><span style="color: #000000">"</span><span style="color: #000000">调用了三个参数的&nbsp;fun&nbsp;函数</span><span style="color: #000000">"</span><span style="color: #000000">&lt;&lt;</span><span style="color: #000000">endl;<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;T&nbsp;tmp&nbsp;</span><span style="color: #000000">=</span><span style="color: #000000">&nbsp;x&nbsp;</span><span style="color: #000000">*</span><span style="color: #000000">&nbsp;x&nbsp;</span><span style="color: #000000">+</span><span style="color: #000000">&nbsp;y&nbsp;</span><span style="color: #000000">*</span><span style="color: #000000">&nbsp;y&nbsp;</span><span style="color: #000000">+</span><span style="color: #000000">&nbsp;z&nbsp;</span><span style="color: #000000">*</span><span style="color: #000000">&nbsp;z&nbsp;</span><span style="color: #000000">+</span><span style="color: #000000">&nbsp;x&nbsp;</span><span style="color: #000000">*</span><span style="color: #000000">&nbsp;y&nbsp;</span><span style="color: #000000">*</span><span style="color: #000000">&nbsp;z;<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">return</span><span style="color: #000000">&nbsp;tmp;<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockEnd.gif"  alt="" />}</span></span><span style="color: #000000"><br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/None.gif"  alt="" /><br /><img id="Codehighlighter1_362_638_Open_Image" onclick="this.style.display='none'; Codehighlighter1_362_638_Open_Text.style.display='none'; Codehighlighter1_362_638_Closed_Image.style.display='inline'; Codehighlighter1_362_638_Closed_Text.style.display='inline';" align="top" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockStart.gif"><img style="display: none" id="Codehighlighter1_362_638_Closed_Image" onclick="this.style.display='none'; Codehighlighter1_362_638_Closed_Text.style.display='none'; Codehighlighter1_362_638_Open_Image.style.display='inline'; Codehighlighter1_362_638_Open_Text.style.display='inline';" align="top" src="http://www.cppblog.com/images/OutliningIndicators/ContractedBlock.gif"></span><span style="color: #0000ff">int</span><span style="color: #000000">&nbsp;main()</span><span style="border-bottom: #808080 1px solid; border-left: #808080 1px solid; background-color: #ffffff; display: none; border-top: #808080 1px solid; border-right: #808080 1px solid" id="Codehighlighter1_362_638_Closed_Text"><img src="http://www.cppblog.com/Images/dot.gif"  alt="" /></span><span id="Codehighlighter1_362_638_Open_Text"><span style="color: #000000">{<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">int</span><span style="color: #000000">&nbsp;x1&nbsp;</span><span style="color: #000000">=</span><span style="color: #000000">&nbsp;</span><span style="color: #000000">1</span><span style="color: #000000">&nbsp;,&nbsp;y1&nbsp;</span><span style="color: #000000">=</span><span style="color: #000000">&nbsp;</span><span style="color: #000000">4</span><span style="color: #000000">&nbsp;,&nbsp;z1&nbsp;</span><span style="color: #000000">=</span><span style="color: #000000">&nbsp;</span><span style="color: #000000">5</span><span style="color: #000000">;<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">float</span><span style="color: #000000">&nbsp;x2&nbsp;</span><span style="color: #000000">=</span><span style="color: #000000">&nbsp;</span><span style="color: #000000">1.1</span><span style="color: #000000">&nbsp;,&nbsp;y2&nbsp;</span><span style="color: #000000">=</span><span style="color: #000000">&nbsp;</span><span style="color: #000000">2.2</span><span style="color: #000000">;<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">double</span><span style="color: #000000">&nbsp;x3&nbsp;</span><span style="color: #000000">=</span><span style="color: #000000">&nbsp;</span><span style="color: #000000">2.0</span><span style="color: #000000">&nbsp;,&nbsp;y3&nbsp;</span><span style="color: #000000">=</span><span style="color: #000000">&nbsp;</span><span style="color: #000000">3.1</span><span style="color: #000000">;<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;cout&nbsp;</span><span style="color: #000000">&lt;&lt;</span><span style="color: #000000">&nbsp;fun(x1,y1)&nbsp;</span><span style="color: #000000">&lt;&lt;</span><span style="color: #000000">&nbsp;endl;<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;cout&nbsp;</span><span style="color: #000000">&lt;&lt;</span><span style="color: #000000">&nbsp;fun(x2,y2)&nbsp;</span><span style="color: #000000">&lt;&lt;</span><span style="color: #000000">&nbsp;endl;<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;cout&nbsp;</span><span style="color: #000000">&lt;&lt;</span><span style="color: #000000">&nbsp;fun(x3,y3)&nbsp;</span><span style="color: #000000">&lt;&lt;</span><span style="color: #000000">&nbsp;endl;<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;cout&nbsp;</span><span style="color: #000000">&lt;&lt;</span><span style="color: #000000">&nbsp;fun(x1,y2)&nbsp;</span><span style="color: #000000">&lt;&lt;</span><span style="color: #000000">&nbsp;endl;<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;cout&nbsp;</span><span style="color: #000000">&lt;&lt;</span><span style="color: #000000">&nbsp;fun(x1,y1,z1)&nbsp;</span><span style="color: #000000">&lt;&lt;</span><span style="color: #000000">&nbsp;endl;<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">return</span><span style="color: #000000">&nbsp;</span><span style="color: #000000">0</span><span style="color: #000000">;<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockEnd.gif"  alt="" />}</span></span><span style="color: #000000"><br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/None.gif"  alt="" /></span><span style="color: #008000">//</span><span style="color: #008000">****************************************</span><span style="color: #008000"><br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/None.gif"  alt="" /></span><span style="color: #000000">#include&nbsp;</span><span style="color: #000000">&lt;</span><span style="color: #000000">iostream</span><span style="color: #000000">&gt;</span><span style="color: #000000"><br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/None.gif"  alt="" /><br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/None.gif"  alt="" /></span><span style="color: #0000ff">using</span><span style="color: #000000">&nbsp;</span><span style="color: #0000ff">namespace</span><span style="color: #000000">&nbsp;std;<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/None.gif"  alt="" /><br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/None.gif"  alt="" />template&nbsp;</span><span style="color: #000000">&lt;</span><span style="color: #000000">typename&nbsp;T</span><span style="color: #000000">&gt;</span><span style="color: #000000"><br /><img id="Codehighlighter1_762_850_Open_Image" onclick="this.style.display='none'; Codehighlighter1_762_850_Open_Text.style.display='none'; Codehighlighter1_762_850_Closed_Image.style.display='inline'; Codehighlighter1_762_850_Closed_Text.style.display='inline';" align="top" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockStart.gif"><img style="display: none" id="Codehighlighter1_762_850_Closed_Image" onclick="this.style.display='none'; Codehighlighter1_762_850_Closed_Text.style.display='none'; Codehighlighter1_762_850_Open_Image.style.display='inline'; Codehighlighter1_762_850_Open_Text.style.display='inline';" align="top" src="http://www.cppblog.com/images/OutliningIndicators/ContractedBlock.gif">T&nbsp;fun(T&nbsp;x,T&nbsp;y)</span><span style="border-bottom: #808080 1px solid; border-left: #808080 1px solid; background-color: #ffffff; display: none; border-top: #808080 1px solid; border-right: #808080 1px solid" id="Codehighlighter1_762_850_Closed_Text"><img src="http://www.cppblog.com/Images/dot.gif"  alt="" /></span><span id="Codehighlighter1_762_850_Open_Text"><span style="color: #000000">{<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;cout&nbsp;</span><span style="color: #000000">&lt;&lt;</span><span style="color: #000000">&nbsp;</span><span style="color: #000000">"</span><span style="color: #000000">调用了模板函数&nbsp;^^&nbsp;</span><span style="color: #000000">"</span><span style="color: #000000">&nbsp;</span><span style="color: #000000">&lt;&lt;</span><span style="color: #000000">&nbsp;endl;<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;T&nbsp;tmp&nbsp;</span><span style="color: #000000">=</span><span style="color: #000000">&nbsp;x&nbsp;</span><span style="color: #000000">*</span><span style="color: #000000">&nbsp;x&nbsp;</span><span style="color: #000000">+</span><span style="color: #000000">&nbsp;y&nbsp;</span><span style="color: #000000">*</span><span style="color: #000000">&nbsp;y&nbsp;</span><span style="color: #000000">+</span><span style="color: #000000">&nbsp;x&nbsp;</span><span style="color: #000000">*</span><span style="color: #000000">&nbsp;y;<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">return</span><span style="color: #000000">&nbsp;tmp;<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockEnd.gif"  alt="" />}</span></span><span style="color: #000000"><br /><img id="Codehighlighter1_872_957_Open_Image" onclick="this.style.display='none'; Codehighlighter1_872_957_Open_Text.style.display='none'; Codehighlighter1_872_957_Closed_Image.style.display='inline'; Codehighlighter1_872_957_Closed_Text.style.display='inline';" align="top" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockStart.gif"><img style="display: none" id="Codehighlighter1_872_957_Closed_Image" onclick="this.style.display='none'; Codehighlighter1_872_957_Closed_Text.style.display='none'; Codehighlighter1_872_957_Open_Image.style.display='inline'; Codehighlighter1_872_957_Open_Text.style.display='inline';" align="top" src="http://www.cppblog.com/images/OutliningIndicators/ContractedBlock.gif"></span><span style="color: #0000ff">int</span><span style="color: #000000">&nbsp;fun(</span><span style="color: #0000ff">int</span><span style="color: #000000">&nbsp;x,</span><span style="color: #0000ff">int</span><span style="color: #000000">&nbsp;y)</span><span style="border-bottom: #808080 1px solid; border-left: #808080 1px solid; background-color: #ffffff; display: none; border-top: #808080 1px solid; border-right: #808080 1px solid" id="Codehighlighter1_872_957_Closed_Text"><img src="http://www.cppblog.com/Images/dot.gif"  alt="" /></span><span id="Codehighlighter1_872_957_Open_Text"><span style="color: #000000">{<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;cout&nbsp;</span><span style="color: #000000">&lt;&lt;</span><span style="color: #000000">&nbsp;</span><span style="color: #000000">"</span><span style="color: #000000">调用了非模板函数</span><span style="color: #000000">"</span><span style="color: #000000">&lt;&lt;</span><span style="color: #000000">endl;<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">int</span><span style="color: #000000">&nbsp;tmp&nbsp;</span><span style="color: #000000">=</span><span style="color: #000000">&nbsp;x&nbsp;</span><span style="color: #000000">*</span><span style="color: #000000">&nbsp;x&nbsp;</span><span style="color: #000000">+</span><span style="color: #000000">&nbsp;y&nbsp;</span><span style="color: #000000">*</span><span style="color: #000000">&nbsp;y&nbsp;</span><span style="color: #000000">+</span><span style="color: #000000">&nbsp;x&nbsp;</span><span style="color: #000000">*</span><span style="color: #000000">&nbsp;y;<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">return</span><span style="color: #000000">&nbsp;tmp;<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockEnd.gif"  alt="" />}</span></span><span style="color: #000000"><br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/None.gif"  alt="" /><br /><img id="Codehighlighter1_970_1106_Open_Image" onclick="this.style.display='none'; Codehighlighter1_970_1106_Open_Text.style.display='none'; Codehighlighter1_970_1106_Closed_Image.style.display='inline'; Codehighlighter1_970_1106_Closed_Text.style.display='inline';" align="top" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockStart.gif"><img style="display: none" id="Codehighlighter1_970_1106_Closed_Image" onclick="this.style.display='none'; Codehighlighter1_970_1106_Closed_Text.style.display='none'; Codehighlighter1_970_1106_Open_Image.style.display='inline'; Codehighlighter1_970_1106_Open_Text.style.display='inline';" align="top" src="http://www.cppblog.com/images/OutliningIndicators/ContractedBlock.gif"></span><span style="color: #0000ff">int</span><span style="color: #000000">&nbsp;main()</span><span style="border-bottom: #808080 1px solid; border-left: #808080 1px solid; background-color: #ffffff; display: none; border-top: #808080 1px solid; border-right: #808080 1px solid" id="Codehighlighter1_970_1106_Closed_Text"><img src="http://www.cppblog.com/Images/dot.gif"  alt="" /></span><span id="Codehighlighter1_970_1106_Open_Text"><span style="color: #000000">{<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">int</span><span style="color: #000000">&nbsp;x1&nbsp;</span><span style="color: #000000">=</span><span style="color: #000000">&nbsp;</span><span style="color: #000000">1</span><span style="color: #000000">&nbsp;,&nbsp;y1&nbsp;</span><span style="color: #000000">=</span><span style="color: #000000">&nbsp;</span><span style="color: #000000">4</span><span style="color: #000000">;<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">float</span><span style="color: #000000">&nbsp;x2&nbsp;</span><span style="color: #000000">=</span><span style="color: #000000">&nbsp;</span><span style="color: #000000">1.1</span><span style="color: #000000">&nbsp;,&nbsp;y2&nbsp;</span><span style="color: #000000">=</span><span style="color: #000000">&nbsp;</span><span style="color: #000000">2.2</span><span style="color: #000000">;<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;cout&nbsp;</span><span style="color: #000000">&lt;&lt;</span><span style="color: #000000">&nbsp;fun(x1,y1)&nbsp;</span><span style="color: #000000">&lt;&lt;</span><span style="color: #000000">&nbsp;endl;<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;cout&nbsp;</span><span style="color: #000000">&lt;&lt;</span><span style="color: #000000">&nbsp;fun(x2,y2)&nbsp;</span><span style="color: #000000">&lt;&lt;</span><span style="color: #000000">&nbsp;endl;<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">return</span><span style="color: #000000">&nbsp;</span><span style="color: #000000">0</span><span style="color: #000000">;<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockEnd.gif"  alt="" />}</span></span><span style="color: #000000"><br /><img id="Codehighlighter1_1108_1274_Open_Image" onclick="this.style.display='none'; Codehighlighter1_1108_1274_Open_Text.style.display='none'; Codehighlighter1_1108_1274_Closed_Image.style.display='inline'; Codehighlighter1_1108_1274_Closed_Text.style.display='inline';" align="top" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockStart.gif"><img style="display: none" id="Codehighlighter1_1108_1274_Closed_Image" onclick="this.style.display='none'; Codehighlighter1_1108_1274_Closed_Text.style.display='none'; Codehighlighter1_1108_1274_Open_Image.style.display='inline'; Codehighlighter1_1108_1274_Open_Text.style.display='inline';" align="top" src="http://www.cppblog.com/images/OutliningIndicators/ContractedBlock.gif"></span><span style="border-bottom: #808080 1px solid; border-left: #808080 1px solid; background-color: #ffffff; display: none; border-top: #808080 1px solid; border-right: #808080 1px solid" id="Codehighlighter1_1108_1274_Closed_Text">/**/</span><span id="Codehighlighter1_1108_1274_Open_Text"><span style="color: #008000">/*</span><span style="color: #008000">*****************************<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" /><br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />看以看出模版函数和非模板函数也是可能重载的，<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />那么重载函数的调用顺序是怎么样的呢？实际上是先查找非模板函数，<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />要有严格匹配的非模板函数，就调用非模板函数，<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />找不到适合的非模板函数在和模板函数进行匹配。<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" /><br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockEnd.gif"  alt="" />******************************</span><span style="color: #008000">*/</span></span><span style="color: #000000"><br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/None.gif"  alt="" /><br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/None.gif"  alt="" /><br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/None.gif"  alt="" /></span></span></div><img src ="http://www.cppblog.com/Achiber/aggbug/195615.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/Achiber/" target="_blank">王文豪</a> 2012-11-23 22:33 <a href="http://www.cppblog.com/Achiber/archive/2012/11/23/195615.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>模板函数</title><link>http://www.cppblog.com/Achiber/archive/2012/11/23/195614.html</link><dc:creator>王文豪</dc:creator><author>王文豪</author><pubDate>Fri, 23 Nov 2012 14:17:00 GMT</pubDate><guid>http://www.cppblog.com/Achiber/archive/2012/11/23/195614.html</guid><wfw:comment>http://www.cppblog.com/Achiber/comments/195614.html</wfw:comment><comments>http://www.cppblog.com/Achiber/archive/2012/11/23/195614.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/Achiber/comments/commentRss/195614.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/Achiber/services/trackbacks/195614.html</trackback:ping><description><![CDATA[<div style="border-bottom: #cccccc 1px solid; border-left: #cccccc 1px solid; padding-bottom: 4px; background-color: #eeeeee; padding-left: 4px; width: 98%; padding-right: 5px; font-size: 13px; word-break: break-all; border-top: #cccccc 1px solid; border-right: #cccccc 1px solid; padding-top: 4px"><!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />--><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/None.gif"  alt="" /><span style="color: #000000">#include&nbsp;</span><span style="color: #000000">&lt;</span><span style="color: #000000">iostream</span><span style="color: #000000">&gt;</span><span style="color: #000000"><br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/None.gif"  alt="" />#include&nbsp;</span><span style="color: #000000">&lt;</span><span style="color: #000000">cstdio</span><span style="color: #000000">&gt;</span><span style="color: #000000"><br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/None.gif"  alt="" /></span><span style="color: #0000ff">using</span><span style="color: #000000">&nbsp;</span><span style="color: #0000ff">namespace</span><span style="color: #000000">&nbsp;std;<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/None.gif"  alt="" /><br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/None.gif"  alt="" />template&nbsp;</span><span style="color: #000000">&lt;</span><span style="color: #000000">typename&nbsp;T1&nbsp;,&nbsp;typename&nbsp;T2</span><span style="color: #000000">&gt;</span><span style="color: #000000"><br /><img id="Codehighlighter1_114_169_Open_Image" onclick="this.style.display='none'; Codehighlighter1_114_169_Open_Text.style.display='none'; Codehighlighter1_114_169_Closed_Image.style.display='inline'; Codehighlighter1_114_169_Closed_Text.style.display='inline';" align="top" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockStart.gif"><img style="display: none" id="Codehighlighter1_114_169_Closed_Image" onclick="this.style.display='none'; Codehighlighter1_114_169_Closed_Text.style.display='none'; Codehighlighter1_114_169_Open_Image.style.display='inline'; Codehighlighter1_114_169_Open_Text.style.display='inline';" align="top" src="http://www.cppblog.com/images/OutliningIndicators/ContractedBlock.gif">T2&nbsp;fun(T1&nbsp;x,T2&nbsp;y)</span><span style="border-bottom: #808080 1px solid; border-left: #808080 1px solid; background-color: #ffffff; display: none; border-top: #808080 1px solid; border-right: #808080 1px solid" id="Codehighlighter1_114_169_Closed_Text"><img src="http://www.cppblog.com/Images/dot.gif"  alt="" /></span><span id="Codehighlighter1_114_169_Open_Text"><span style="color: #000000">{<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;T2&nbsp;tmp&nbsp;</span><span style="color: #000000">=</span><span style="color: #000000">&nbsp;x&nbsp;</span><span style="color: #000000">*</span><span style="color: #000000">x&nbsp;</span><span style="color: #000000">+</span><span style="color: #000000">&nbsp;y&nbsp;</span><span style="color: #000000">*</span><span style="color: #000000">&nbsp;y&nbsp;</span><span style="color: #000000">+</span><span style="color: #000000">&nbsp;x&nbsp;</span><span style="color: #000000">*</span><span style="color: #000000">&nbsp;y;<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">return</span><span style="color: #000000">&nbsp;tmp;<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockEnd.gif"  alt="" />}</span></span><span style="color: #000000"><br /><img id="Codehighlighter1_181_424_Open_Image" onclick="this.style.display='none'; Codehighlighter1_181_424_Open_Text.style.display='none'; Codehighlighter1_181_424_Closed_Image.style.display='inline'; Codehighlighter1_181_424_Closed_Text.style.display='inline';" align="top" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockStart.gif"><img style="display: none" id="Codehighlighter1_181_424_Closed_Image" onclick="this.style.display='none'; Codehighlighter1_181_424_Closed_Text.style.display='none'; Codehighlighter1_181_424_Open_Image.style.display='inline'; Codehighlighter1_181_424_Open_Text.style.display='inline';" align="top" src="http://www.cppblog.com/images/OutliningIndicators/ContractedBlock.gif"></span><span style="color: #0000ff">int</span><span style="color: #000000">&nbsp;main()</span><span style="border-bottom: #808080 1px solid; border-left: #808080 1px solid; background-color: #ffffff; display: none; border-top: #808080 1px solid; border-right: #808080 1px solid" id="Codehighlighter1_181_424_Closed_Text"><img src="http://www.cppblog.com/Images/dot.gif"  alt="" /></span><span id="Codehighlighter1_181_424_Open_Text"><span style="color: #000000">{<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">int</span><span style="color: #000000">&nbsp;x1&nbsp;</span><span style="color: #000000">=</span><span style="color: #000000">&nbsp;</span><span style="color: #000000">1</span><span style="color: #000000">,&nbsp;y1&nbsp;</span><span style="color: #000000">=</span><span style="color: #000000">&nbsp;</span><span style="color: #000000">4</span><span style="color: #000000">;<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">float</span><span style="color: #000000">&nbsp;x2&nbsp;</span><span style="color: #000000">=</span><span style="color: #000000">&nbsp;</span><span style="color: #000000">1.1</span><span style="color: #000000">&nbsp;,&nbsp;y2&nbsp;</span><span style="color: #000000">=</span><span style="color: #000000">&nbsp;</span><span style="color: #000000">2.2</span><span style="color: #000000">;<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">double</span><span style="color: #000000">&nbsp;x3&nbsp;</span><span style="color: #000000">=</span><span style="color: #000000">&nbsp;</span><span style="color: #000000">2.0</span><span style="color: #000000">&nbsp;,&nbsp;y3&nbsp;</span><span style="color: #000000">=</span><span style="color: #000000">&nbsp;</span><span style="color: #000000">3.1</span><span style="color: #000000">;<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;cout&nbsp;</span><span style="color: #000000">&lt;&lt;</span><span style="color: #000000">&nbsp;fun(x1,&nbsp;y1)&nbsp;</span><span style="color: #000000">&lt;&lt;</span><span style="color: #000000">&nbsp;endl;<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;cout&nbsp;</span><span style="color: #000000">&lt;&lt;</span><span style="color: #000000">&nbsp;fun(x2,&nbsp;y2)&nbsp;</span><span style="color: #000000">&lt;&lt;</span><span style="color: #000000">&nbsp;endl;<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;cout&nbsp;</span><span style="color: #000000">&lt;&lt;</span><span style="color: #000000">&nbsp;fun(x3,&nbsp;y3)&nbsp;</span><span style="color: #000000">&lt;&lt;</span><span style="color: #000000">&nbsp;endl;<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;cout&nbsp;</span><span style="color: #000000">&lt;&lt;</span><span style="color: #000000">&nbsp;fun(x1,&nbsp;y2)&nbsp;</span><span style="color: #000000">&lt;&lt;</span><span style="color: #000000">&nbsp;endl;<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">return</span><span style="color: #000000">&nbsp;</span><span style="color: #000000">0</span><span style="color: #000000">;<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockEnd.gif"  alt="" />}</span></span><span style="color: #000000"><br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/None.gif"  alt="" /></span></div>
<div style="border-bottom: #cccccc 1px solid; border-left: #cccccc 1px solid; padding-bottom: 4px; background-color: #eeeeee; padding-left: 4px; width: 98%; padding-right: 5px; font-size: 13px; word-break: break-all; border-top: #cccccc 1px solid; border-right: #cccccc 1px solid; padding-top: 4px"><img id="Code_Closed_Image_221600" onclick="this.style.display='none'; Code_Closed_Text_221600.style.display='none'; Code_Open_Image_221600.style.display='inline'; Code_Open_Text_221600.style.display='inline';" align="top" src="http://www.cppblog.com/images/OutliningIndicators/ContractedBlock.gif" width="11" height="16"><img style="display: none" id="Code_Open_Image_221600" onclick="this.style.display='none'; Code_Open_Text_221600.style.display='none'; Code_Closed_Image_221600.style.display='inline'; Code_Closed_Text_221600.style.display='inline';" align="top" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockStart.gif" width="11" height="16"><span style="border-bottom: #808080 1px solid; border-left: #808080 1px solid; background-color: #ffffff; border-top: #808080 1px solid; border-right: #808080 1px solid" id="Code_Closed_Text_221600"></span><span style="display: none" id="Code_Open_Text_221600"><br /><!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />--><span style="color: #008080">&nbsp;1</span><img alt="" align="top" src="http://www.cppblog.com/images/OutliningIndicators/None.gif" /><span style="color: #000000">#include&nbsp;</span><span style="color: #000000">&lt;</span><span style="color: #000000">iostream</span><span style="color: #000000">&gt;</span><span style="color: #000000"><br /></span><span style="color: #008080">&nbsp;2</span><span style="color: #000000"><img alt="" align="top" src="http://www.cppblog.com/images/OutliningIndicators/None.gif" />#include&nbsp;</span><span style="color: #000000">&lt;</span><span style="color: #000000">cstdio</span><span style="color: #000000">&gt;</span><span style="color: #000000"><br /></span><span style="color: #008080">&nbsp;3</span><span style="color: #000000"><img alt="" align="top" src="http://www.cppblog.com/images/OutliningIndicators/None.gif" /></span><span style="color: #0000ff">using</span><span style="color: #000000">&nbsp;</span><span style="color: #0000ff">namespace</span><span style="color: #000000">&nbsp;std;<br /></span><span style="color: #008080">&nbsp;4</span><span style="color: #000000"><img alt="" align="top" src="http://www.cppblog.com/images/OutliningIndicators/None.gif" /><br /></span><span style="color: #008080">&nbsp;5</span><span style="color: #000000"><img alt="" align="top" src="http://www.cppblog.com/images/OutliningIndicators/None.gif" />template&nbsp;</span><span style="color: #000000">&lt;</span><span style="color: #000000">typename&nbsp;T</span><span style="color: #000000">&gt;</span><span style="color: #000000"><br /></span><span style="color: #008080">&nbsp;6</span><span style="color: #000000"><img id="Codehighlighter1_96_150_Open_Image" onclick="this.style.display='none'; Codehighlighter1_96_150_Open_Text.style.display='none'; Codehighlighter1_96_150_Closed_Image.style.display='inline'; Codehighlighter1_96_150_Closed_Text.style.display='inline';" align="top" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockStart.gif"><img style="display: none" id="Codehighlighter1_96_150_Closed_Image" onclick="this.style.display='none'; Codehighlighter1_96_150_Closed_Text.style.display='none'; Codehighlighter1_96_150_Open_Image.style.display='inline'; Codehighlighter1_96_150_Open_Text.style.display='inline';" align="top" src="http://www.cppblog.com/images/OutliningIndicators/ContractedBlock.gif">T&nbsp;fun(T&nbsp;x,T&nbsp;y)</span><span style="border-bottom: #808080 1px solid; border-left: #808080 1px solid; background-color: #ffffff; display: none; border-top: #808080 1px solid; border-right: #808080 1px solid" id="Codehighlighter1_96_150_Closed_Text"><img alt="" src="http://www.cppblog.com/Images/dot.gif" /></span><span id="Codehighlighter1_96_150_Open_Text"><span style="color: #000000">{<br /></span><span style="color: #008080">&nbsp;7</span><span style="color: #000000"><img alt="" align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;T&nbsp;tmp&nbsp;</span><span style="color: #000000">=</span><span style="color: #000000">&nbsp;x&nbsp;</span><span style="color: #000000">*</span><span style="color: #000000">x&nbsp;</span><span style="color: #000000">+</span><span style="color: #000000">&nbsp;y&nbsp;</span><span style="color: #000000">*</span><span style="color: #000000">&nbsp;y&nbsp;</span><span style="color: #000000">+</span><span style="color: #000000">&nbsp;x&nbsp;</span><span style="color: #000000">*</span><span style="color: #000000">&nbsp;y;<br /></span><span style="color: #008080">&nbsp;8</span><span style="color: #000000"><img alt="" align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">return</span><span style="color: #000000">&nbsp;tmp;<br /></span><span style="color: #008080">&nbsp;9</span><span style="color: #000000"><img alt="" align="top" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockEnd.gif" />}</span></span><span style="color: #000000"><br /></span><span style="color: #008080">10</span><span style="color: #000000"><img id="Codehighlighter1_162_405_Open_Image" onclick="this.style.display='none'; Codehighlighter1_162_405_Open_Text.style.display='none'; Codehighlighter1_162_405_Closed_Image.style.display='inline'; Codehighlighter1_162_405_Closed_Text.style.display='inline';" align="top" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockStart.gif"><img style="display: none" id="Codehighlighter1_162_405_Closed_Image" onclick="this.style.display='none'; Codehighlighter1_162_405_Closed_Text.style.display='none'; Codehighlighter1_162_405_Open_Image.style.display='inline'; Codehighlighter1_162_405_Open_Text.style.display='inline';" align="top" src="http://www.cppblog.com/images/OutliningIndicators/ContractedBlock.gif"></span><span style="color: #0000ff">int</span><span style="color: #000000">&nbsp;main()</span><span style="border-bottom: #808080 1px solid; border-left: #808080 1px solid; background-color: #ffffff; display: none; border-top: #808080 1px solid; border-right: #808080 1px solid" id="Codehighlighter1_162_405_Closed_Text"><img alt="" src="http://www.cppblog.com/Images/dot.gif" /></span><span id="Codehighlighter1_162_405_Open_Text"><span style="color: #000000">{<br /></span><span style="color: #008080">11</span><span style="color: #000000"><img alt="" align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">int</span><span style="color: #000000">&nbsp;x1&nbsp;</span><span style="color: #000000">=</span><span style="color: #000000">&nbsp;</span><span style="color: #000000">1</span><span style="color: #000000">,y1&nbsp;</span><span style="color: #000000">=</span><span style="color: #000000">&nbsp;</span><span style="color: #000000">4</span><span style="color: #000000">;<br /></span><span style="color: #008080">12</span><span style="color: #000000"><img alt="" align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">float</span><span style="color: #000000">&nbsp;x2&nbsp;</span><span style="color: #000000">=</span><span style="color: #000000">&nbsp;</span><span style="color: #000000">1.1</span><span style="color: #000000">&nbsp;,&nbsp;y2&nbsp;</span><span style="color: #000000">=</span><span style="color: #000000">&nbsp;</span><span style="color: #000000">2.2</span><span style="color: #000000">;<br /></span><span style="color: #008080">13</span><span style="color: #000000"><img alt="" align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">double</span><span style="color: #000000">&nbsp;x3&nbsp;</span><span style="color: #000000">=</span><span style="color: #000000">&nbsp;</span><span style="color: #000000">2.0</span><span style="color: #000000">&nbsp;,&nbsp;y3&nbsp;</span><span style="color: #000000">=</span><span style="color: #000000">&nbsp;</span><span style="color: #000000">3.1</span><span style="color: #000000">;<br /></span><span style="color: #008080">14</span><span style="color: #000000"><img alt="" align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;cout&nbsp;</span><span style="color: #000000">&lt;&lt;</span><span style="color: #000000">&nbsp;fun(x1,&nbsp;y1)&nbsp;</span><span style="color: #000000">&lt;&lt;</span><span style="color: #000000">&nbsp;endl;<br /></span><span style="color: #008080">15</span><span style="color: #000000"><img alt="" align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #008000">//</span><span style="color: #008000">cout&nbsp;&lt;&lt;&nbsp;fun(x1,&nbsp;y2)&nbsp;&lt;&lt;&nbsp;endl;</span><span style="color: #008000"><br /></span><span style="color: #008080">16</span><span style="color: #008000"><img alt="" align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" /></span><span style="color: #000000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;cout&nbsp;</span><span style="color: #000000">&lt;&lt;</span><span style="color: #000000">&nbsp;fun(x2,&nbsp;y2)&nbsp;</span><span style="color: #000000">&lt;&lt;</span><span style="color: #000000">&nbsp;endl;<br /></span><span style="color: #008080">17</span><span style="color: #000000"><img alt="" align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;cout&nbsp;</span><span style="color: #000000">&lt;&lt;</span><span style="color: #000000">&nbsp;fun(x3,&nbsp;y3)&nbsp;</span><span style="color: #000000">&lt;&lt;</span><span style="color: #000000">endl;<br /></span><span style="color: #008080">18</span><span style="color: #000000"><img alt="" align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">return</span><span style="color: #000000">&nbsp;</span><span style="color: #000000">0</span><span style="color: #000000">;<br /></span><span style="color: #008080">19</span><span style="color: #000000"><img alt="" align="top" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockEnd.gif" />}</span></span><span style="color: #000000"><br /></span><span style="color: #008080">20</span><span style="color: #000000"><img alt="" align="top" src="http://www.cppblog.com/images/OutliningIndicators/None.gif" /></span></span></div><img src ="http://www.cppblog.com/Achiber/aggbug/195614.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/Achiber/" target="_blank">王文豪</a> 2012-11-23 22:17 <a href="http://www.cppblog.com/Achiber/archive/2012/11/23/195614.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>