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

            導航

            <2013年7月>
            30123456
            78910111213
            14151617181920
            21222324252627
            28293031123
            45678910

            統(tǒng)計

            留言簿(6)

            隨筆分類(109)

            隨筆檔案(105)

            Blogers

            Game

            Life

            NodeJs

            Python

            Useful Webs

            大牛

            搜索

            積分與排名

            最新評論

            閱讀排行榜

            評論排行榜

            成人精品一区二区久久 | 欧美午夜A∨大片久久| 久久精品成人欧美大片| 亚洲午夜福利精品久久| 久久久久99精品成人片欧美| 88久久精品无码一区二区毛片 | 青青热久久综合网伊人| 午夜福利91久久福利| 久久精品国产亚洲av日韩| 久久久久亚洲AV无码专区桃色 | 久久国产高清字幕中文| 国产99久久久国产精品小说| 久久精品麻豆日日躁夜夜躁| 久久嫩草影院免费看夜色| 久久Av无码精品人妻系列| 亚洲欧美一区二区三区久久| 91久久精品无码一区二区毛片| 久久99精品久久久大学生| 99久久国产主播综合精品| 久久精品国产亚洲av水果派| 人妻无码精品久久亚瑟影视| 久久免费大片| 久久五月精品中文字幕| 国产成人精品综合久久久| 久久久综合九色合综国产| 精品熟女少妇av免费久久| 亚洲精品tv久久久久久久久| 伊人久久国产免费观看视频| 欧美日韩中文字幕久久久不卡| 久久综合亚洲色HEZYO国产| 久久久久无码精品| 人妻丰满?V无码久久不卡| 理论片午午伦夜理片久久| 久久露脸国产精品| 看全色黄大色大片免费久久久| 深夜久久AAAAA级毛片免费看| 国产精品免费久久久久影院| 色偷偷888欧美精品久久久| 国产免费久久精品99久久| 精品熟女少妇aⅴ免费久久| 色综合久久久久综合99|