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

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

            關(guān)于使用命名空間及聲明外部變量的練習(xí)

            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 閱讀(519) 評(píng)論(0)  編輯 收藏 引用 所屬分類: C++基礎(chǔ)

            導(dǎo)航

            <2009年3月>
            22232425262728
            1234567
            891011121314
            15161718192021
            22232425262728
            2930311234

            統(tǒng)計(jì)

            留言簿(6)

            隨筆分類(109)

            隨筆檔案(105)

            Blogers

            Game

            Life

            NodeJs

            Python

            Useful Webs

            大牛

            搜索

            積分與排名

            最新評(píng)論

            閱讀排行榜

            評(píng)論排行榜

            久久婷婷成人综合色综合| 精品乱码久久久久久夜夜嗨| 久久久精品日本一区二区三区| 久久精品国产亚洲AV香蕉| 亚洲成色www久久网站夜月| 久久久亚洲欧洲日产国码是AV| 一本色道久久88综合日韩精品| 蜜臀久久99精品久久久久久| 久久涩综合| 亚洲а∨天堂久久精品| 日批日出水久久亚洲精品tv| 中文字幕久久亚洲一区| 色天使久久综合网天天| 亚洲色婷婷综合久久| 日韩精品无码久久久久久| 亚洲国产精品久久久天堂| 9久久9久久精品| 久久一区二区三区免费| 久久亚洲国产精品成人AV秋霞| 久久综合亚洲欧美成人| 日本精品久久久久中文字幕8 | 国产成人无码精品久久久性色 | 97香蕉久久夜色精品国产| 亚洲人成精品久久久久| 97久久超碰国产精品旧版| 2021国产成人精品久久| 亚洲国产成人久久综合一区77| 久久精品国产精品亚洲精品| 狠狠色丁香婷婷久久综合不卡| 欧美无乱码久久久免费午夜一区二区三区中文字幕 | 久久久久人妻精品一区三寸蜜桃 | 国产三级精品久久| 久久久久久久91精品免费观看| 亚洲国产欧美国产综合久久| 久久久久综合网久久| 无码国内精品久久综合88| 久久这里只精品国产99热 | 色综合久久久久综合体桃花网| 亚洲国产精品一区二区久久| 欧美亚洲国产精品久久| 99久久国产主播综合精品|