• <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++ && keyWordSpotting

              C++博客 :: 首頁 :: 聯系 :: 聚合  :: 管理
              11 Posts :: 0 Stories :: 4 Comments :: 0 Trackbacks

            常用鏈接

            留言簿(9)

            我參與的團隊

            搜索

            •  

            積分與排名

            • 積分 - 7242
            • 排名 - 1369

            最新評論

            閱讀排行榜

            評論排行榜

            Introduction

            1. A declaration tells compilers about the name and type of an object, function, class, or template, but it omits certain details.

            2. A definition, on the other hand, provides compilers with the details. For an object, the definition is where compilers allocate memory for the object. For a function or a function template, the definition provides the code body. For a class or a class template, the definition lists the members of the class or template.

            3. When you define a class, you generally need a default constructor if you want to define arrays of objects.Incidentally, if you want to create an array of objects for which there is no default constructor, the usual ploy is to define an array of pointers instead. Then you can initialize each pointer separately by using new.

            4. Probably the most important use of the copy constructor is to define what it means to pass and return objects by value.

            5. From a purely operational point of view, the difference between initialization and assignment is that the former is performed by a constructor while the latter is performed by operator=. In other words, the two processes correspond to different function calls. The reason for the distinction is that the two kinds of functions must worry about different things. Constructors usually have to check their arguments for validity, whereas most assignment operators can take it for granted that their argument is legitimate (because it has already been constructed). On the other hand, the target of an assignment, unlike an object undergoing construction, may already have resources allocated to it. These resources typically must be released before the new resources can be assigned. Frequently, one of these resources is memory. Before an assignment operator can allocate memory for a new value, it must first deallocate the memory that was allocated for the old value.

            // ?a?possible?String?constructor
            String::String( const ? char ? * value)
            {
            ????
            if ?(value)
            ????
            {?
            ????????
            // ?if?value?ptr?isn't?null
            ????????data? = ? new ? char [strlen(value)? + ? 1 ];
            ????????strcpy(data,value);
            ????}
            ????
            ????
            else ?
            ????
            {?
            ????????
            // ?handle?null?value?ptr3
            ????????data? = ? new ? char [ 1 ];
            ????????
            * data? = ? ' \0 ' ;? // ?add?trailing
            ???????? null ? char
            ????}

            }


            // ?a?possible?String?assignment?operator

            String
            & ?String:: operator = ( const ?String & ?rhs)
            {
            ????
            if ?( this ? == ? & rhs)
            ????????
            return ? * this ;? // ?see?Item?17

            ????delete?[]?data;?
            // ?delete?old?memory
            ????
            ????data?
            = ? // ?allocate?new?memory
            ???????? new ? char [strlen(rhs.data)? + ? 1 ];

            ????strcpy(data,?rhs.data);
            ????
            ????
            return ? * this ;? // ?see?Item?15
            }


            6. These different casting forms serve different purposes:

            const_cast is designed to cast away the constness of objects and pointers, a topic I examine in Item 21.

            dynamic_cast is used to perform "safe downcasting," a subject we'll explore in Item 39.

            reinterpret_cast is engineered for casts that yield implementation-dependent results, e.g., casting between function pointer types. (You're not likely to need reinterpret_cast very often. I don't use it at all in this book.)

            static_cast is sort of the catch-all cast. It's what you use when none of the other casts is appropriate. It's the closest in meaning to the conventional C-style casts.

            posted on 2006-08-20 16:10 keyws 閱讀(353) 評論(0)  編輯 收藏 引用 所屬分類: 讀書筆記
            精品久久久久久久久久久久久久久 | 久久久久久久久无码精品亚洲日韩 | 99久久精品国产一区二区| 久久精品aⅴ无码中文字字幕不卡| 久久精品国产免费观看三人同眠| 97久久国产露脸精品国产| 青青草国产精品久久| 久久亚洲AV无码西西人体| 亚洲AV成人无码久久精品老人| 国产精品丝袜久久久久久不卡| 久久久久久精品无码人妻| 99热精品久久只有精品| 亚洲中文久久精品无码ww16| 香蕉久久一区二区不卡无毒影院| 日韩人妻无码一区二区三区久久99| 久久国产成人精品麻豆| 久久久久国产精品人妻| 国内精品久久久久久不卡影院| 无码国内精品久久人妻蜜桃| 欧美日韩中文字幕久久久不卡| 久久国产精品成人免费 | 久久高清一级毛片| 久久99国产精品久久久| 日韩精品久久久肉伦网站| 无码乱码观看精品久久| 精品国产青草久久久久福利| 91久久精一区二区三区大全| 色偷偷88888欧美精品久久久| 亚洲国产综合久久天堂| 久久se这里只有精品| 久久国产V一级毛多内射| 狠狠人妻久久久久久综合| 亚洲国产精品久久久久婷婷软件| 久久久久久午夜成人影院| 无码人妻精品一区二区三区久久久| 欧美一区二区久久精品| 久久婷婷午色综合夜啪| 少妇无套内谢久久久久| 狠狠综合久久综合88亚洲| 一本久道久久综合狠狠爱| 亚洲国产精品18久久久久久|