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

我輩豈是蓬蒿人!

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>
            亚洲电影免费| 亚洲国产成人精品女人久久久| 国产精品99久久久久久久久久久久| 欧美激情1区2区| 亚洲经典在线| 一区二区三区四区精品| aa级大片欧美三级| 亚洲午夜视频| 欧美亚洲日本国产| 美国成人直播| 国产精品高潮视频| 国自产拍偷拍福利精品免费一| 在线观看不卡| 亚洲一区www| 老司机久久99久久精品播放免费| 欧美激情第五页| 一本久道久久久| 久久久精品久久久久| 欧美日本在线一区| 国产乱码精品| 亚洲美女在线视频| 久久久久国产一区二区三区四区 | 欧美伊人精品成人久久综合97 | 欧美一区二视频| 欧美伊人影院| 亚洲欧美福利一区二区| 久久精品视频播放| 欧美日本在线观看| 亚洲国产日韩欧美在线动漫| 亚洲欧美一区二区三区久久| 美女视频黄免费的久久| 亚洲永久视频| 欧美日韩国产在线播放| 亚洲国产精品一区二区www| 欧美尤物一区| 性欧美video另类hd性玩具| 国产精品久久久91| 中国成人亚色综合网站| 亚洲精品资源美女情侣酒店| 男人的天堂成人在线| 国内精品久久久久影院优| 麻豆精品传媒视频| 国产精品亚洲成人| 欧美一区视频在线| 午夜精品视频在线| 亚洲成色777777在线观看影院| 久久久久久久一区| 久久久久久亚洲精品中文字幕 | 久久久成人精品| 亚洲欧洲精品一区二区| 久久精品一区二区| 久久久九九九九| 91久久亚洲| 亚洲一区二区三区中文字幕| 国产日韩亚洲| 亚洲精品黄色| 国产精品国产福利国产秒拍| 另类激情亚洲| 亚洲一区中文字幕在线观看| 欧美一级大片在线免费观看| 精品动漫一区二区| 亚洲在线一区二区三区| 亚洲欧洲精品一区二区三区波多野1战4| 亚洲第一黄网| 国产一区二区主播在线 | 一本综合久久| 久久久亚洲欧洲日产国码αv| 亚洲欧美成人精品| 欧美精品国产一区| 欧美国产视频在线| 韩国一区电影| 久久精品国产成人| 亚洲在线观看视频网站| 欧美成人日本| 亚洲黑丝一区二区| 亚洲精品一二三区| 蜜臀av性久久久久蜜臀aⅴ四虎| 欧美在线播放一区| 国产乱码精品一区二区三区av| 一区二区三区国产在线| 亚洲色图在线视频| 欧美韩国一区| 亚洲日本欧美| 欧美区一区二| 午夜精品电影| 久久久久国产精品厨房| 精品成人在线观看| 久热精品在线| 亚洲婷婷综合色高清在线| 亚洲一区二区成人| 国产一区视频在线观看免费| 久久久夜夜夜| 日韩一级黄色av| 国产精品久久久久高潮| 亚洲永久在线观看| 亚洲成色www8888| 亚洲综合视频1区| 国内精品视频一区| 欧美伦理a级免费电影| 午夜精品三级视频福利| 亚洲福利专区| 久久精品亚洲| 制服丝袜亚洲播放| 国外成人免费视频| 欧美视频在线观看一区| 久久理论片午夜琪琪电影网| 亚洲精品一区中文| 欧美一区二区三区日韩| 在线视频亚洲欧美| 亚洲伦理精品| 最新精品在线| 99精品免费| 亚洲色图制服丝袜| 亚洲伊人色欲综合网| 一区二区不卡在线视频 午夜欧美不卡在 | 欧美电影免费观看网站| 久久久久**毛片大全| 亚洲欧美影院| 亚洲国产岛国毛片在线| 欧美日韩在线高清| 欧美成人综合一区| 欧美aⅴ一区二区三区视频| 欧美一激情一区二区三区| 亚洲欧美文学| 另类天堂av| 欧美日韩免费视频| 国产精品国产三级国产专区53| 欧美激情第1页| 欧美国产精品专区| 国产婷婷色一区二区三区在线 | 亚洲欧美电影在线观看| 亚洲一区二区三区四区在线观看 | 欧美日韩另类字幕中文| 欧美色播在线播放| 国产精品一区二区三区四区| 国语自产精品视频在线看| 亚洲欧洲日本mm| 亚洲综合色噜噜狠狠| 欧美电影免费观看高清完整版| 亚洲毛片在线观看.| 久久久久久9| 欧美午夜精品伦理| 在线精品国产欧美| 亚洲男人影院| 99re66热这里只有精品3直播| 久久精品免费播放| 国产日韩在线播放| 亚洲欧美成人一区二区三区| 亚洲高清三级视频| 久久精品亚洲热| 国产在线国偷精品产拍免费yy| 亚洲视频第一页| 亚洲乱码日产精品bd| 欧美精品1区2区| 亚洲视频免费观看| 一区二区不卡在线视频 午夜欧美不卡在| 久久成年人视频| 好男人免费精品视频| 久久精品国产精品亚洲| 亚洲一区二区三区精品动漫| 国产精品啊啊啊| 久久久天天操| 欧美电影免费网站| 亚洲免费在线精品一区| 亚洲欧美日韩一区二区三区在线| 欧美视频在线看| 欧美成人国产va精品日本一级| 亚洲电影在线看| 亚洲狼人综合| 国外精品视频| 中文亚洲免费| 91久久精品一区| 亚洲午夜激情网页| 一区二区三区在线视频免费观看| 麻豆成人综合网| 国产精品一区二区男女羞羞无遮挡| 久久黄金**| 欧美日韩在线视频观看| 麻豆精品在线播放| 国产精品夜夜嗨| 亚洲精品中文字幕有码专区| 国产欧美日韩精品一区| 夜夜嗨av色综合久久久综合网| 国产亚洲激情在线| 一区二区三区欧美视频| 最新日韩精品| 久热精品视频| 久久婷婷成人综合色| 国产精品一区免费在线观看| 91久久久在线| 亚洲高清视频的网址| 久久久久久久久蜜桃| 欧美在线亚洲| 国产一区白浆| 久久久久久久国产| 亚洲精品国产精品国自产在线| 亚洲国产精品一区| 欧美va天堂va视频va在线| 欧美激情欧美狂野欧美精品| 亚洲国产高清在线|