• <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 閱讀(523) 評論(0)  編輯 收藏 引用 所屬分類: C++基礎

            導航

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

            統計

            留言簿(6)

            隨筆分類(109)

            隨筆檔案(105)

            Blogers

            Game

            Life

            NodeJs

            Python

            Useful Webs

            大牛

            搜索

            積分與排名

            最新評論

            閱讀排行榜

            評論排行榜

            午夜视频久久久久一区 | 久久精品国产亚洲AV无码麻豆| 久久久无码精品午夜| 亚洲国产日韩欧美久久| 97精品依人久久久大香线蕉97| 久久综合给久久狠狠97色| 国产韩国精品一区二区三区久久| 99久久精品国产毛片| 久久99热这里只频精品6| 97久久国产露脸精品国产| 99久久精品费精品国产 | 欧美久久久久久| 久久精品一区二区三区不卡| 天天综合久久一二三区| 久久国产亚洲精品麻豆| 中文字幕久久亚洲一区| 精品久久一区二区| 国产色综合久久无码有码| 伊人久久免费视频| 久久精品国产亚洲av日韩| 欧美亚洲另类久久综合婷婷| 99久久99久久久精品齐齐| 久久精品免费一区二区| 精品无码久久久久久久动漫| 国内精品人妻无码久久久影院 | 成人久久精品一区二区三区 | 国产亚州精品女人久久久久久 | 久久精品国产亚洲Aⅴ香蕉| 久久无码人妻一区二区三区午夜| 久久夜色精品国产亚洲av| 久久美女网站免费| 国产一区二区精品久久| 久久亚洲国产成人精品性色| 少妇无套内谢久久久久| 蜜桃麻豆www久久国产精品| 夜夜亚洲天天久久| 91久久福利国产成人精品| 伊人色综合久久| 精品国产婷婷久久久| 久久丝袜精品中文字幕| 久久激情亚洲精品无码?V|