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

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

            關于使用命名空間及聲明外部變量的練習

            File1
            #include <string>

            namespace data {
                
            // The next two variables have external linkage
                int count;                // will be initialized to 9 by default
                float phi = 1.618f;        // the divine proportion or golden ratio

                
            // without the extern, the following would not be accessible
                
            // from another file because they would have internal linkage
                extern const double pi = 3.14159265;
                
            extern const std::string days[] = { "Sunday""Monday""Tuesday""Wednesday""Thursday""Friday""Saturday" };
            }


            File2
            #include <iostream>
            #include 
            <string>
            #include 
            <iomanip>

            namespace data {
                
            //Declare external variables
                extern float phi;
                
            extern const double pi;
                
            extern const std::string days[];
                
            extern int count;
            }

            void main() {
                std::cout 
            << std::setprecision(3<< std::fixed;
                std::cout 
            << std::endl
                    
            << "To 3 decimal places" << std::endl;

                std::cout 
            << " a circle with a diameter of phi has an area of"
                    
            << data::pi * data::phi * data::phi /4
                     
            << std::endl;

                std::cout 
            << "phi squared is " << data::phi * data::phi << std::endl;
                std::cout 
            << " in fact, phi+1 is also " << data::phi+1 << std::endl;

                std::cout 
            << "value of count is " << data::count << std::endl;

                data::count 
            += 3;
                std::cout 
            << "today is " << data::days[data::count] << std::endl;
            }

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

            導航

            <2013年7月>
            30123456
            78910111213
            14151617181920
            21222324252627
            28293031123
            45678910

            統(tǒng)計

            留言簿(6)

            隨筆分類(109)

            隨筆檔案(105)

            Blogers

            Game

            Life

            NodeJs

            Python

            Useful Webs

            大牛

            搜索

            積分與排名

            最新評論

            閱讀排行榜

            評論排行榜

            伊人久久久AV老熟妇色| 青青青青久久精品国产h| 国产成人综合久久精品红| 久久久无码精品亚洲日韩京东传媒| 狠狠色狠狠色综合久久| 国产婷婷成人久久Av免费高清| 国内精品免费久久影院| 久久人人添人人爽添人人片牛牛| 久久久久久a亚洲欧洲aⅴ| 伊人久久五月天| 久久综合丁香激情久久| 亚洲乱码中文字幕久久孕妇黑人| 久久国产精品免费一区二区三区| 久久精品国产亚洲AV蜜臀色欲| 久久久久夜夜夜精品国产| 久久久久久久女国产乱让韩| 99久久国产主播综合精品| 午夜久久久久久禁播电影| 伊人久久大香线蕉无码麻豆| 久久93精品国产91久久综合| 国产91色综合久久免费分享| 99精品久久精品一区二区| 久久强奷乱码老熟女网站| 亚洲国产精品婷婷久久| 国产精品久久成人影院| 久久精品国产亚洲AV麻豆网站 | 91麻豆国产精品91久久久| 99精品久久久久久久婷婷| 久久精品国产亚洲综合色| 国产午夜免费高清久久影院| 久久久久亚洲AV片无码下载蜜桃 | 国产精品久久久久久吹潮| 成人午夜精品无码区久久| 狠狠色丁香婷婷久久综合五月| 四虎国产精品成人免费久久| 久久国产免费直播| 久久人人爽人人爽AV片| 欧美精品九九99久久在观看| 热久久视久久精品18| 亚洲熟妇无码另类久久久| 久久精品毛片免费观看|