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

            c++實(shí)例研究

            從0開始

              C++博客 :: 首頁 :: 新隨筆 :: 聯(lián)系 :: 聚合  :: 管理 ::
              104 隨筆 :: 0 文章 :: 20 評(píng)論 :: 0 Trackbacks
            /*
              Name: Why C++ ?(2)(plus on/off funtion)
              Copyright: 
              Author: elprup
              Date: 08/10/10 09:18
              Description: 
            */
            #include 
            <cstdio>
            #include 
            <cstdlib>
            #include 
            <iostream>
            using namespace std;

            //on/off for c on/off function
            bool on = true;

            int print(const char* s)
            {
                
            extern bool on;
                
            if(on)
                    printf(
            "%s\n", s);
                
            return 0;    
            }

            void badguy()
            {
                
            extern bool on;
                on 
            = false//modify global varity
                return;
            }

            class trace_cpp
            {
            public:
                
            //easy to initial state of class, but c need special attention.
                trace_cpp():m_on(true){}
                
            int print(const char*s)const{if(m_on) printf("%s\n", s); return 0;}
                
            int on(){m_on = truereturn 0;}
                
            int off(){m_on = falsereturn 0;}
            private:
                
            //add class related varity, not see out of class
                bool m_on;
            };

            int main()
            {
                
            //c style trace
                print("Hello from c.");
                
                
            //cpp style trace;
                trace_cpp tc;
                tc.print(
            "Hello from c++");
                
                
            //turn on/off c style trace
                extern bool on;
                on 
            = false;
                print(
            "Wont display from c.");
                on 
            = true;
                print(
            "Will display from c.");
                
            //it looks working fine, but if foo() modify it?
                badguy();
                print(
            "Want to display, but won't from c.");
                
                
            //turn on/off cpp style
                tc.off();
                tc.print(
            "Wont display from cpp.");
                tc.on();
                tc.print(
            "Will display from cpp.");
                
            //so we hardly find a function to modify state of trace cpp
                
                system(
            "PAUSE");
                
            return 0;
            }
            posted on 2010-10-08 09:45 elprup 閱讀(413) 評(píng)論(0)  編輯 收藏 引用 所屬分類: c++實(shí)例
            99久久er这里只有精品18| 999久久久免费国产精品播放| 欧美久久综合九色综合| 亚洲а∨天堂久久精品9966| 久久午夜夜伦鲁鲁片免费无码影视 | 久久精品国产乱子伦| 99久久精品费精品国产| 国产精品一区二区久久精品涩爱 | 国产精品久久久99| 性欧美丰满熟妇XXXX性久久久| 狠狠色伊人久久精品综合网| 久久妇女高潮几次MBA| 久久久久亚洲AV无码专区桃色| 天天躁日日躁狠狠久久| 免费一级欧美大片久久网| 久久99精品久久久久久久久久| 色婷婷噜噜久久国产精品12p| www性久久久com| 中文字幕久久精品无码| 久久综合亚洲色HEZYO国产 | 欧美午夜精品久久久久免费视| 久久久久国产一区二区 | 一级a性色生活片久久无| 狠狠色丁香婷婷综合久久来来去| 久久久久久亚洲AV无码专区| 久久www免费人成看片| 亚洲人AV永久一区二区三区久久| 久久精品国产第一区二区| 久久国产免费观看精品| 国产综合久久久久| 精品人妻久久久久久888| 一本色道久久88精品综合| 久久天天躁夜夜躁狠狠躁2022| 午夜精品久久久久9999高清| 久久天天日天天操综合伊人av| 国产精品免费久久久久影院| 国产 亚洲 欧美 另类 久久| 成人精品一区二区久久| 久久精品夜色噜噜亚洲A∨| 色99久久久久高潮综合影院| 99精品国产免费久久久久久下载|