• <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年7月>
            27282930123
            45678910
            11121314151617
            18192021222324
            25262728293031
            1234567

            統計

            留言簿(6)

            隨筆分類(109)

            隨筆檔案(105)

            Blogers

            Game

            Life

            NodeJs

            Python

            Useful Webs

            大牛

            搜索

            積分與排名

            最新評論

            閱讀排行榜

            評論排行榜

            国内精品人妻无码久久久影院 | 久久婷婷是五月综合色狠狠| 青青青伊人色综合久久| 91精品久久久久久无码| 亚洲国产高清精品线久久| 伊人久久综合成人网| 国产亚洲欧美成人久久片| 99久久人人爽亚洲精品美女| AV无码久久久久不卡蜜桃| 国产精品久久久久久影院| 久久久久久亚洲精品无码| 香蕉久久夜色精品升级完成| 久久99热国产这有精品| 人人妻久久人人澡人人爽人人精品| 色狠狠久久AV五月综合| 欧美精品一区二区久久| a高清免费毛片久久| 2021国产精品久久精品| 久久高潮一级毛片免费| 久久久久亚洲精品无码蜜桃| 午夜视频久久久久一区 | 无码任你躁久久久久久老妇| 国产成人精品三上悠亚久久| 久久久久久久综合日本| 久久中文字幕一区二区| 久久久精品2019免费观看| 伊人久久大香线蕉亚洲五月天| 九九热久久免费视频| 91久久精品电影| 久久国产成人精品麻豆| 精品无码久久久久国产| 亚洲色欲久久久综合网| 国产精品一区二区久久精品涩爱| 国产毛片久久久久久国产毛片 | 亚洲精品乱码久久久久久蜜桃不卡| 久久综合精品国产一区二区三区| 99热成人精品免费久久| 久久99久久成人免费播放| 精品久久久久中文字| 久久免费大片| 一级做a爰片久久毛片毛片|