• <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>

            liyuxia713

            蹣跚前行者

            常用鏈接

            統(tǒng)計

            Algorithms

            C++

            最新評論

            [導(dǎo)入]模板編譯模型

            1.包含編譯模型(inclusion compilation model). 函數(shù)聲明放在頭文件中,定義放在源文件中。頭文件尾包含源文件。據(jù)說會出現(xiàn)一個模板實例化多次從而導(dǎo)致編譯時性能顯著降低。

            //template.cpp
            template<typename T>
            void print(const T &v)
            {
                cout << "T = " << v <<endl;
            }

            //template.h
            #ifndef TEMPLATE_H
            #define TEMPLATE_H

            template<typename T>
            void print(const T &v);

            #include "template.cpp" 

            #endif

            //main.cpp
            #include<iostream>
            #include "template.h"  
            //#include"template.cpp" 用這條命令代替也可以。

            using namespace std;

            int main()
            {
               
            print(1); //ok
                return 0;
            }

            2. 分別編譯模型(seperate compilation model).函數(shù)聲明和類定義放在頭文件中,帶export關(guān)鍵字的函數(shù)定義和類聲明放在源文件中。源文件尾包含頭文件。(不知道理解的對不對,用的編譯器不支持分別編譯,暫時無從判斷了

            //the template definition goes in a separately-compiled source file

            export template<typename T>

            T print(const T&v) /*...*/

            //class template header goes in shared header file

            template <class T> class cl{...};

            //cl.cpp implementation file declares cl as exported

            export template <class T> class cl;

            #include "cl.h"

            //cl member definitions


            文章來源:http://liyuxia-life.spaces.live.com/Blog/cns!DA1B364675ACF35!265.entry

            posted on 2009-03-24 15:50 幸運草 閱讀(509) 評論(0)  編輯 收藏 引用 所屬分類: C++

            色综合久久天天综线观看| 思思久久99热只有频精品66| 国产成人无码精品久久久性色| 久久久黄色大片| 久久Av无码精品人妻系列| 国产精品青草久久久久福利99| 性高朝久久久久久久久久| 久久久久人妻一区精品色| 久久本道久久综合伊人| 人妻精品久久久久中文字幕69| 国产成人无码精品久久久久免费| 怡红院日本一道日本久久| 久久亚洲AV无码精品色午夜| 99精品久久精品| 精品久久久无码人妻中文字幕| 99久久99久久精品国产片果冻| 亚洲va国产va天堂va久久| 国产91色综合久久免费| 无码人妻久久一区二区三区蜜桃| 久久久无码精品亚洲日韩按摩| 久久久精品日本一区二区三区| 国产精品久久久久久久| 久久人人爽人人爽人人av东京热 | 国产美女亚洲精品久久久综合| 亚洲国产精品一区二区久久| 97久久国产综合精品女不卡| 欧美精品福利视频一区二区三区久久久精品 | 亚洲人成精品久久久久| 午夜精品久久影院蜜桃| 久久精品国产99久久香蕉| 伊人久久精品无码二区麻豆| 亚洲国产精品久久久久久| 亚洲午夜久久久久久久久电影网 | 久久66热人妻偷产精品9| 狠狠色综合网站久久久久久久高清 | 久久91精品国产91| 久久影视综合亚洲| 久久久高清免费视频| 2021国内精品久久久久久影院| 亚洲AV伊人久久青青草原| 2022年国产精品久久久久|