青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品

我輩豈是蓬蒿人!

C++ && keyWordSpotting

  C++博客 :: 首頁(yè) :: 聯(lián)系 :: 聚合  :: 管理
  11 Posts :: 0 Stories :: 4 Comments :: 0 Trackbacks

常用鏈接

留言簿(9)

我參與的團(tuán)隊(duì)

搜索

  •  

積分與排名

  • 積分 - 7323
  • 排名 - 1369

最新評(píng)論

閱讀排行榜

評(píng)論排行榜

Shifting from C to C++

1. To C++ programmer, for example, a pointer to a pointer looks a little funny. Why, we wonder, wasn’t a reference to a pointer used ?instead?

?????? const char chr[] = "chenzhenshi&guohonghua";

?????? const char*? pchr = chr;

?????? const char** ppchr = &pchr;

?????? const char*&? rpchr? = pchr; // a reference to a pointer

?????? std::cout << pchr << ' ' << *ppchr << ' ' << rpchr << std::endl;

?

2. C is a fairly simple language. All it really offers is macros, pointers, structs, arrays, and functions. No matter what the problem is, the solution will always boil down to macros, pointers, structs, arrays, and functions. Not so in C++. The macros, pointers, structs, arrays and functions are still there, of course, but so are private and protected members, function overloading, default parameters, constructors and destructors, user-defined operators, inline functions, references, friends, templates, exceptions, namespaces, and more. The design space is much richer in C++ than it is in C: there are just a lot more options to consider.

Item 1: Prefer const and inline to #define

3. The Item might better be called “prefer the compiler to the preprocessor”.

4. ?? const char* pc;

?????? pc = a1;

?????? std::cout << pc << std::endl;

?????? pc = a2;

?????? std::cout << pc << std::endl;

?

?????? const char* const pcc = "a const pointer to a const char array";

?????? std::cout << pcc << std::endl;

?????? // error C2166: l-value specifies const object

?????? // pcc = a1;? // error!

?????? std::cout << pcc << std::endl;

5. You can define a const variable in a class, but it must be static const, and have a definition in an implementation file.

// .h file

class try_const

{

public:

?????? static const int num;

};

// .cxx file

const int try_const::num = 250;

6. You can get all the efficiency of a macro plus all the predictable behavior and type safety of a regular function by using an inline function.

Template <class type>

Inline const type& max (const type& a, const type& b)

{

Return a > b ? a : b ;

}

7. Given the availability of consts and inlines, your need for the preprocessor is reduced, but it's not completely eliminated. The day is far from near when you can abandon #include, and #ifdef/#ifndef continue to play important roles in controlling compilation. It's not yet time to retire the preprocessor, but you should definitely plan to start giving it longer and more frequent vacations.

Item 2: Prefer <iostream> to <stdio.h>

8. ?scanf and printf are not type-safe and extensible.

9.? In particular, if you #include <iostream>, you get the elements of the iostream library ensconced within the namespace std (see Item 28), but if you #include <iostream.h>, you get those same elements at global scope. Getting them at global scope can lead to name conflicts, precisely the kinds of name conflicts the use of namespaces is designed to prevent.

Item 3: Prefer new and delete to malloc and free

10. The problem with malloc and free(and their variants) is simple : they don’t know about constructors and destructors.

11. free 操作不會(huì)調(diào)用析構(gòu)函數(shù),如果指針?biāo)笇?duì)象本身又分配了內(nèi)存,則會(huì)造成內(nèi)存丟失。

Item 4: Prefer C++ style comments

Memory Management

12. Memory management concerns in C++ fall into two general camps: getting it right and making it perform efficiently.

Item 5: Use the same form in corresponding uses of new and delete

13. When you use new, two things happen. First, memory is allocated. Second, one or more constructors are called for that memory. When you use delete, two other things happen: one or more destructors are called for the memory, then the memory is deallocated.

14. The standard C++ library includes string and vector templates that reduce the need for built-in arrays to nearly zero.

Item 6: Use delete on pointer members in destructors

15. Speaking of smart pointers, one way to avoid the need to delete pointer members is to replace those members with smart pointer objects like the standard C++ Library’s auto_ptr.

Item 7: Be prepared for out-of-memory conditions

Item 8: Adhere to convention when writing operator new and operator delete

Item 9: Avoid hiding the “normal” form of new

Item 10: Write operator delete if you write operator new

讓我們回過頭去看看這樣一個(gè)基本問題:為什么有必要寫自己的 operator new operator delete ?答案通常是:為了效率。缺省的 operator new operator delete 具有非常好的通用性,它的這種靈活性也使得在某些特定的場(chǎng)合下,可以進(jìn)一步改善它的性能。尤其在那些需要?jiǎng)討B(tài)分配大量的但很小的對(duì)象的應(yīng)用程序里,情況更是如此。

?

posted on 2006-08-22 17:24 keyws 閱讀(531) 評(píng)論(0)  編輯 收藏 引用 所屬分類: 讀書筆記
青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <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>
            欧美凹凸一区二区三区视频| 欧美影院成年免费版| 欧美精品v国产精品v日韩精品| 亚洲综合色丁香婷婷六月图片| 亚洲免费av电影| 日韩写真在线| 一区二区高清在线| 亚洲无线一线二线三线区别av| 一区二区三区四区国产| 中日韩美女免费视频网址在线观看 | 亚洲国产精品毛片| 91久久久久久久久| 亚洲激情啪啪| 日韩网站在线观看| 99re热精品| 一区二区三区四区蜜桃| 一本综合久久| 亚洲欧美日韩在线综合| 亚洲欧美在线看| 久久久久久夜| 欧美激情在线| 亚洲高清在线观看一区| 亚洲电影在线| 亚洲一区二区三区三| 新67194成人永久网站| 久久久久国产精品一区三寸| 猛男gaygay欧美视频| 欧美激情第二页| 国产精品日韩欧美综合 | 国产精品一二三四| 曰本成人黄色| 久久亚洲精品网站| 欧美怡红院视频一区二区三区| 欧美在线视频在线播放完整版免费观看| 久久久亚洲国产天美传媒修理工 | 欧美激情中文字幕一区二区| 日韩亚洲在线| 久久综合五月天婷婷伊人| 欧美日韩国产麻豆| 一区二区在线视频播放| 亚洲制服少妇| 噜噜噜躁狠狠躁狠狠精品视频 | 亚洲青涩在线| 亚洲午夜电影网| 欧美wwwwww| 国产日韩在线看| 中国av一区| 欧美成人日韩| 亚洲欧美日本国产有色| 欧美国产综合视频| 国产日韩欧美一区二区三区在线观看| 久久精品91| 国产精品成人久久久久| 在线播放国产一区中文字幕剧情欧美| 亚洲欧美欧美一区二区三区| 亚洲国产黄色| 欧美一区二区三区在线观看| 欧美日韩在线另类| 亚洲激情自拍| 久久综合色综合88| 一道本一区二区| 国产精品久久久对白| 午夜精品剧场| 一区二区三区四区国产精品| 欧美日韩精品欧美日韩精品| 夜夜爽99久久国产综合精品女不卡 | 国产欧美日韩一区二区三区在线观看| 一区二区三区视频观看| 亚洲三级性片| 欧美日韩精品久久| 午夜精品在线看| 亚洲欧美一区二区原创| 国产精品成av人在线视午夜片| 亚洲天堂久久| 一本大道久久a久久综合婷婷| 欧美精品一卡| 亚洲小视频在线| 亚洲精品一区二区在线| 国产精品v日韩精品v欧美精品网站 | 久久久久久9999| 一本久道久久久| 久久av一区二区三区漫画| 欧美一区二区三区免费视频| 欧美成人激情视频免费观看| 国产精品久久7| 亚洲国产另类 国产精品国产免费| 欧美激情亚洲视频| 欧美午夜在线一二页| 久久精品国产精品亚洲综合| 亚洲激情女人| 久久精品30| 国产欧美va欧美va香蕉在| 亚洲日本一区二区| 久久夜色精品亚洲噜噜国产mv| 老妇喷水一区二区三区| 国产精品美女久久久久久2018 | 亚洲精品一二| 亚洲成人原创| 亚洲天堂成人在线视频| 欧美激情第一页xxx| 国产亚洲精品综合一区91| 日韩午夜在线观看视频| 久久久久久久久伊人| 亚洲一区二区网站| 欧美精品高清视频| 欧美国产精品专区| 久久久久国产精品一区三寸| 夜夜精品视频一区二区| 欧美精品麻豆| 99在线视频精品| 亚洲精品乱码久久久久久| 久久婷婷影院| 狠狠色香婷婷久久亚洲精品| 在线观看的日韩av| 亚洲伊人观看| 欧美色欧美亚洲另类二区| 日韩一级裸体免费视频| 好看的日韩视频| 亚洲日本电影在线| 午夜一区二区三视频在线观看| 亚洲福利视频一区| 久久精品免费观看| 国产精品少妇自拍| 亚洲一区二区三区视频播放| 亚洲成人在线视频播放 | 久久久久久久久久久久久女国产乱| 国产欧美日韩视频| 黄色国产精品一区二区三区| 亚洲精品国产精品久久清纯直播| 女生裸体视频一区二区三区| 国产一区二区三区日韩欧美| 欧美在线一二三| 午夜精品成人在线| 亚洲国产高清aⅴ视频| 亚洲午夜三级在线| 国产欧美视频在线观看| 久久久久国产精品一区三寸| 欧美v日韩v国产v| 国产片一区二区| 日韩午夜激情av| 久久亚洲综合色一区二区三区| 91久久精品美女高潮| 国产精品黄视频| 久久九九国产精品| 鲁大师影院一区二区三区| 亚洲另类一区二区| 亚洲欧洲三级| 夜夜夜久久久| 欧美中文字幕第一页| 亚洲三级影片| 亚洲欧美日本在线| 亚洲精品乱码久久久久久蜜桃91 | 欧美激情网友自拍| 亚洲视频在线看| 久久成人精品视频| 日韩亚洲成人av在线| 久久九九热re6这里有精品| 国产日韩欧美一区在线| 亚洲欧洲一区二区天堂久久 | 日韩午夜在线视频| 亚洲私拍自拍| 好看的av在线不卡观看| 99精品99| 午夜久久99| 麻豆精品精华液| 亚洲欧美99| 久久亚洲综合| 中文亚洲免费| 久久久久久久999精品视频| 夜夜爽99久久国产综合精品女不卡 | 国产精品99久久久久久有的能看 | 欧美多人爱爱视频网站| 欧美亚洲免费高清在线观看| 欧美凹凸一区二区三区视频| 黑人巨大精品欧美一区二区| 欧美国产精品久久| 美国十次成人| 国产伦精品一区二区三区在线观看 | 亚洲第一伊人| 欧美理论电影在线播放| 久久全国免费视频| 国产精品成人一区二区艾草| 久久夜精品va视频免费观看| 国产美女搞久久| 亚洲高清视频一区| 欧美日韩国产三区| 欧美激情第8页| 激情综合久久| 午夜久久久久久| 性欧美长视频| 欧美四级在线| 欧美激情亚洲| 日韩特黄影片| 中文一区二区在线观看| 欧美精品xxxxbbbb| 亚洲电影免费观看高清完整版在线观看 | 亚洲在线免费视频| 欧美色欧美亚洲另类二区| 亚洲精品自在在线观看| 99国产成+人+综合+亚洲欧美|