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

            為中華之崛起而崛起!
            兼聽(tīng)則明,偏聽(tīng)則暗。

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

            導(dǎo)航

            <2009年4月>
            2930311234
            567891011
            12131415161718
            19202122232425
            262728293012
            3456789

            統(tǒng)計(jì)

            留言簿(6)

            隨筆分類(109)

            隨筆檔案(105)

            Blogers

            Game

            Life

            NodeJs

            Python

            Useful Webs

            大牛

            搜索

            積分與排名

            最新評(píng)論

            閱讀排行榜

            評(píng)論排行榜

            亚洲综合伊人久久综合| 久久久黄色大片| 很黄很污的网站久久mimi色| 色天使久久综合网天天| 国产成人综合久久久久久 | 亚洲午夜久久久久久久久久| 久久天天躁狠狠躁夜夜网站| 久久AV高潮AV无码AV| 亚洲精品美女久久久久99小说 | 99re这里只有精品热久久| 超级97碰碰碰碰久久久久最新 | 国产69精品久久久久99尤物| 77777亚洲午夜久久多喷| 久久国产精品久久久| 国产亚洲欧美成人久久片 | 无码国内精品久久人妻| 一本大道久久东京热无码AV| 久久婷婷国产麻豆91天堂| 久久精品国产亚洲av水果派| 久久久久亚洲精品天堂| 久久亚洲欧洲国产综合| 亚洲国产精品综合久久一线 | 国产香蕉久久精品综合网| 9久久9久久精品| 久久精品蜜芽亚洲国产AV| 久久久www免费人成精品| 欧美久久久久久| 亚洲国产成人久久综合野外| 久久精品免费大片国产大片| 性高朝久久久久久久久久| 亚洲国产高清精品线久久| 国产精品日韩深夜福利久久| 一本色道久久88加勒比—综合| 久久久久久一区国产精品| 777米奇久久最新地址| 精品久久久久久国产| 女人香蕉久久**毛片精品| 2021国产成人精品久久| 国产综合免费精品久久久| 国产精品久久久久久久午夜片| 久久精品国产亚洲AV不卡|