• <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開(kāi)始

              C++博客 :: 首頁(yè) :: 新隨筆 :: 聯(lián)系 :: 聚合  :: 管理 ::
              104 隨筆 :: 0 文章 :: 20 評(píng)論 :: 0 Trackbacks

             

            /*  
            *    Doc Name: Basic Concepts: constructor, copy constructor,
            *                assignment operation
            *    Prob Id: -
            *    Serial Id: A.2.2
            *    Author: -
            *    Env: Microsoft Visual Studio 2008 Win32 Console
            *    Date: 10/10/27
            */


            #include 
            "stdafx.h"
            #include 
            <iostream>
            using namespace std;

            class A
            {
            public:
                A()
            {cout<<"ctor"<<endl;}
                A(
            int i){cout<<"ctor int"<<endl;}
                A(
            const A& src){cout<<"copy ctor"<<endl;}
                A
            & operator=(const A& rhs){cout<<"assgin op"<<endl; return (*this);}
            }
            ;

            void println(const int n)
            {
                cout
            <<"------- case "<<n<<"-------"<<endl;
            }


            A
            & getInstRef()
            {
                A
            * p = new A();
                
            return *p; 
            }


            A getInst()
            {
                A
            * p = new A();
                
            return *p;
            }


            int _tmain(int argc, _TCHAR* argv[])
            {
                println(
            1);
                A instA; 
            //ctor in stack
                println(2);
                A
            * pint;  //nothing done
                println(3);
                pint 
            = new A(); //ctor heap
                
                println(
            4);
                A instAA(instA); 
            //copy ctor
                println(5);
                A instAAA 
            = instA; //copy ctor
                
                println(
            6);
                instAA 
            = instAAA; //assign op
                
                println(
            7);
                A instAAAA 
            = getInstRef(); //temp instance - return refrence to construct
                println(8);
                instAAAA 
            = getInstRef(); //temp instance - return refrence to copy construct
                
                println(
            9);
                A instA5 
            = getInst(); //temp instance - return instance to construct
                println(10);
                instA5 
            = getInst(); //temp instance - return instance to copy construct

                println(
            11);
                A instA6 
            = 3;
                println(
            12);
                A instA7;
                instA7 
            = 4;

                
            return 0;
            }


            posted on 2010-10-27 20:37 elprup 閱讀(182) 評(píng)論(0)  編輯 收藏 引用

            只有注冊(cè)用戶(hù)登錄后才能發(fā)表評(píng)論。
            網(wǎng)站導(dǎo)航: 博客園   IT新聞   BlogJava   博問(wèn)   Chat2DB   管理


            久久久久国产亚洲AV麻豆| 欧美激情精品久久久久久久| 东方aⅴ免费观看久久av| 中文字幕久久精品无码| 久久精品国产精品亚洲精品| 97超级碰碰碰碰久久久久| 国产精品内射久久久久欢欢| 中文字幕精品久久| 久久精品草草草| 久久久久久国产精品美女| 四虎影视久久久免费| 日韩乱码人妻无码中文字幕久久 | 久久久久久国产精品无码下载| 久久久无码精品亚洲日韩蜜臀浪潮| 99久久国产主播综合精品| 亚洲中文字幕无码一久久区| 久久99精品久久久久久9蜜桃| 亚洲精品乱码久久久久久| 久久丝袜精品中文字幕| 久久国产精品国产自线拍免费| 精品久久久无码人妻中文字幕 | 久久狠狠高潮亚洲精品| 久久久久久国产精品无码下载 | 国内精品九九久久久精品| 欧美伊人久久大香线蕉综合69 | 国产成人精品久久| 精品久久久久久中文字幕| 亚洲中文久久精品无码| 日韩久久久久中文字幕人妻| 99久久久久| 大美女久久久久久j久久| 国产欧美一区二区久久| 精品久久久无码人妻中文字幕豆芽 | 国产精品久久久久AV福利动漫| 精品久久亚洲中文无码| 久久这里都是精品| 日韩精品无码久久一区二区三| 久久人搡人人玩人妻精品首页| 久久精品免费大片国产大片| 久久久久久国产精品无码下载| 久久精品国产一区二区 |