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

我輩豈是蓬蒿人!

C++ && keyWordSpotting

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

常用鏈接

留言簿(9)

我參與的團隊

搜索

  •  

積分與排名

  • 積分 - 7323
  • 排名 - 1369

最新評論

閱讀排行榜

評論排行榜

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 操作不會調用析構函數,如果指針所指對象本身又分配了內存,則會造成內存丟失。

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

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

?

posted on 2006-08-22 17:24 keyws 閱讀(531) 評論(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>
            午夜在线视频一区二区区别| 一区二区三区国产| 欧美久久婷婷综合色| 国产模特精品视频久久久久 | 一区二区精品| 麻豆9191精品国产| 亚洲欧美在线另类| 欧美日韩一区不卡| 亚洲美女在线国产| 欧美成在线观看| 久久九九精品| 国内精品久久久久久影视8| 欧美在线日韩| 亚洲免费中文字幕| 国产精品一区二区欧美| 亚洲免费网站| 亚洲一区二区三区三| 国产精品videossex久久发布| 夜久久久久久| av成人毛片| 国产精品二区在线| 欧美一区成人| 欧美一区视频| 一区二区视频免费在线观看| 蜜桃av一区二区三区| 久久人人爽人人爽爽久久| 国内精品久久久久国产盗摄免费观看完整版| 午夜精品电影| 久久成人一区| 亚洲国产精品999| 亚洲黄色小视频| 欧美成人精品激情在线观看| 亚洲黄色影院| 99re热这里只有精品视频| 国产精品久久久久久久9999| 欧美专区日韩专区| 久久九九全国免费精品观看| 亚洲人成免费| 亚洲香蕉在线观看| 国内揄拍国内精品久久| 欧美激情一区二区三区四区| 欧美激情一区| 亚洲女人天堂av| 久久国产视频网站| 亚洲美女在线看| 亚洲欧美激情一区二区| 曰韩精品一区二区| 日韩视频中文字幕| 国产在线麻豆精品观看| 亚洲国产成人久久综合| 亚洲国内在线| 午夜欧美不卡精品aaaaa| 激情综合色丁香一区二区| 亚洲国产日韩欧美在线99| 国产精品蜜臀在线观看| 久久综合给合久久狠狠色 | 欧美剧在线免费观看网站| 亚洲香蕉视频| 久久久久久噜噜噜久久久精品| a91a精品视频在线观看| 欧美一区二区三区在线看| 亚洲精品免费在线| 性久久久久久久久| 国内成+人亚洲| 国产欧美日韩综合精品二区| 黄色成人av网站| 香蕉久久夜色| 久久精品首页| 亚洲午夜高清视频| 久久亚洲不卡| 亚洲淫性视频| 免费在线观看日韩欧美| 久久精品导航| 欧美性大战久久久久久久| 欧美福利一区| 国产一区日韩二区欧美三区| 一区二区三区.www| 亚洲韩国日本中文字幕| 久久av资源网站| 亚洲欧美日韩精品久久亚洲区 | 一道本一区二区| 亚洲性视频h| 亚洲精品欧美激情| 久久精品久久综合| 篠田优中文在线播放第一区| 欧美日韩直播| 亚洲精品网站在线播放gif| 亚洲国产精品一区二区www在线| 欧美一区二区三区的| 午夜精品久久久久久久99水蜜桃| 欧美日韩福利视频| 亚洲精品久久7777| 亚洲欧洲综合| 麻豆精品精品国产自在97香蕉| 久久久久久久久久久久久久一区| 国产精品一区在线观看你懂的| 妖精视频成人观看www| 在线视频日本亚洲性| 欧美日韩一区二区三区高清| 亚洲美女中文字幕| 99re8这里有精品热视频免费| 欧美韩国在线| 亚洲国产91| av不卡在线| 欧美网站在线| 久久久久网址| 亚洲欧美国产视频| 国产精品亚洲综合一区在线观看 | 亚洲一区二区三区高清不卡| 99热这里只有精品8| 欧美日韩视频第一区| 在线综合亚洲| 欧美影院在线播放| 黄网站色欧美视频| 欧美成人tv| 在线综合欧美| 久热国产精品| 99国产成+人+综合+亚洲欧美| 欧美日韩在线直播| 欧美一区二区视频免费观看| 欧美成人精品| 亚洲无线视频| 国产真实乱偷精品视频免| 久久这里只有精品视频首页| 亚洲电影毛片| 亚洲欧美精品一区| 国产一区二区久久精品| 免费久久精品视频| 一区二区三区欧美在线| 久久精品伊人| 亚洲精品韩国| 国产精品私拍pans大尺度在线| 欧美在线免费视屏| 亚洲黄色有码视频| 久久久久久久999精品视频| 99re成人精品视频| 国产亚洲精久久久久久| 欧美福利视频一区| 先锋影音国产精品| 亚洲精品欧美激情| 久久人人爽爽爽人久久久| 亚洲最新在线| 在线观看国产一区二区| 国产精品福利网| 欧美插天视频在线播放| 亚洲欧美日韩在线| 亚洲美女av在线播放| 久久综合激情| 亚洲欧美在线观看| 夜夜嗨网站十八久久| 狠色狠色综合久久| 国产精品三级视频| 欧美裸体一区二区三区| 久久久国产一区二区| 正在播放欧美一区| 亚洲大片免费看| 久久久噜噜噜久噜久久| 亚洲欧美www| 日韩网站在线看片你懂的| 尤物在线精品| 国产专区一区| 国产精品影片在线观看| 欧美日韩在线免费观看| 欧美国产日本| 久久一区视频| 久久精品国产欧美激情| 午夜免费久久久久| 亚洲欧美日韩一区在线| 亚洲免费在线播放| 国产精品99久久久久久久久久久久| 亚洲国产清纯| 亚洲第一区在线观看| 久久午夜羞羞影院免费观看| 欧美一区二区在线免费观看| 亚洲欧美日韩国产精品| 亚洲欧美激情精品一区二区| 亚洲一区二三| 亚洲欧美激情在线视频| 亚洲九九爱视频| 蜜臀99久久精品久久久久久软件| 亚洲免费视频观看| 一区二区三区高清视频在线观看| 亚洲精美视频| 亚洲黄色一区| 日韩亚洲不卡在线| 一区二区国产日产| 在线一区欧美| 亚洲男女自偷自拍| 亚洲无线一线二线三线区别av| 国产精品99久久久久久有的能看| 中文成人激情娱乐网| 亚洲美女黄色片| 国产精品99久久久久久有的能看 | 99re6热在线精品视频播放速度 | 欧美韩日一区二区三区| 欧美精品一区二区在线播放| 欧美日韩和欧美的一区二区| 欧美午夜激情在线| 国产欧美精品日韩| 在线精品观看|