• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>

            luqingfei@C++

            為中華之崛起而崛起!
            兼聽則明,偏聽則暗。

            關于函數模板及其重載的練習

            #include <iostream>
            #include 
            <string>
            using std::cout;
            using std::endl;
            using std::string;

            //Template function prototype
            template<class T> T plus(const T& a, const T& b);
            string plus(const string& a, const string& b);

            void main() {
                cout 
            << "plus(3, 4) = " << plus(34<< endl;
                cout 
            << "plus(3.2, 4.2) = " << plus(3.24.2<< endl;
                cout 
            << "plus(\"he\", \"llo\") = " << plus(static_cast<string>("he"), static_cast<string>("llo")) << endl;
                
                cout 
            << "plus(static_cast<double>(3), 4.2) = " << plus(static_cast<double>(3), 4.2<< endl;
                cout 
            << "plus(3, static_cast<int>(4.2)) = " << plus(3, static_cast<int>(4.2)) << endl;

            }

            template
            <class T> T plus(const T& a, const T& b) {
                
            return a + b;
            }

            string plus(const string& a, const string& b) {
                cout 
            << "specifica" << endl;
                
            return a + b;
            }

            運行結果:
            plus(3, 4) = 7
            plus(3.2, 4.2) = 7.4
            specifica
            plus("he", "llo") = hello
            plus(static_cast<double>(3), 4.2) = 7.2
            plus(3, static_cast<int>(4.2)) = 7

            posted on 2009-02-13 17:53 luqingfei 閱讀(274) 評論(0)  編輯 收藏 引用 所屬分類: C++基礎

            導航

            <2010年8月>
            25262728293031
            1234567
            891011121314
            15161718192021
            22232425262728
            2930311234

            統計

            留言簿(6)

            隨筆分類(109)

            隨筆檔案(105)

            Blogers

            Game

            Life

            NodeJs

            Python

            Useful Webs

            大牛

            搜索

            積分與排名

            最新評論

            閱讀排行榜

            評論排行榜

            色综合久久无码中文字幕| 国产欧美久久久精品| 日批日出水久久亚洲精品tv| 日日狠狠久久偷偷色综合免费| 久久综合精品国产一区二区三区| 热99RE久久精品这里都是精品免费| 欧美日韩精品久久免费| 亚洲综合久久综合激情久久| 亚洲精品无码久久不卡| 久久精品国产91久久麻豆自制| 久久久久国色AV免费观看| 久久99精品久久久久子伦| 99久久做夜夜爱天天做精品| 99久久伊人精品综合观看| 色欲综合久久躁天天躁蜜桃| 日本国产精品久久| 国产精品成人精品久久久| 国产成年无码久久久久毛片| 久久久精品久久久久影院| 国内精品免费久久影院| 久久精品嫩草影院| 国产亚洲欧美精品久久久| 亚洲女久久久噜噜噜熟女| 一日本道伊人久久综合影| 久久精品亚洲男人的天堂| www亚洲欲色成人久久精品| 波多野结衣中文字幕久久| 婷婷伊人久久大香线蕉AV | 久久久国产乱子伦精品作者 | 久久亚洲国产成人影院| 精品久久人人妻人人做精品| 91精品国产91久久久久福利| 久久久婷婷五月亚洲97号色 | 麻豆一区二区99久久久久| 久久热这里只有精品在线观看| 久久人人爽人人澡人人高潮AV| 国产福利电影一区二区三区久久老子无码午夜伦不| 国产A三级久久精品| 麻豆AV一区二区三区久久| 精品久久人妻av中文字幕| 久久国产精品久久国产精品|