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

            導(dǎo)航

            <2025年5月>
            27282930123
            45678910
            11121314151617
            18192021222324
            25262728293031
            1234567

            統(tǒng)計(jì)

            留言簿(6)

            隨筆分類(109)

            隨筆檔案(105)

            Blogers

            Game

            Life

            NodeJs

            Python

            Useful Webs

            大牛

            搜索

            積分與排名

            最新評論

            閱讀排行榜

            評論排行榜

            久久99国产乱子伦精品免费| 久久91精品国产91| 国产福利电影一区二区三区久久老子无码午夜伦不 | 91麻精品国产91久久久久| 亚洲国产精品婷婷久久| 久久亚洲视频| 91视频国产91久久久| 成人精品一区二区久久| 亚洲а∨天堂久久精品9966| 热re99久久精品国99热| 精品久久久久国产免费| 久久精品青青草原伊人| 国产精品久久久久久久午夜片 | 亚洲欧洲日产国码无码久久99| 久久福利青草精品资源站免费| 精品久久久久久久国产潘金莲| 久久久精品人妻一区二区三区蜜桃 | 亚洲午夜久久久久妓女影院| 久久精品无码一区二区三区| 久久人妻少妇嫩草AV蜜桃| 久久国产精品免费一区| 久久午夜伦鲁片免费无码| 亚洲国产高清精品线久久| 久久久WWW成人免费毛片| 99国产欧美精品久久久蜜芽| 中文字幕无码久久精品青草 | 亚洲国产精品热久久| 国产亚洲综合久久系列| 久久久久高潮综合影院| 午夜精品久久久久| 久久国产香蕉一区精品| 成人精品一区二区久久久| 久久精品国产91久久麻豆自制| 久久综合综合久久综合| 国产偷久久久精品专区| 97久久国产综合精品女不卡| 欧美久久久久久| 无码久久精品国产亚洲Av影片| 亚洲日本va中文字幕久久| 中文字幕无码精品亚洲资源网久久| 久久久久久精品无码人妻|