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

我輩豈是蓬蒿人!

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>
            国产精品午夜视频| 欧美一区二区三区四区视频| 亚洲专区在线视频| 一区二区高清在线| aa级大片欧美三级| 亚洲一区二区免费看| 亚洲欧美中文字幕| 久色婷婷小香蕉久久| 欧美chengren| 一本色道久久综合亚洲精品不| 亚洲一区二区三区涩| 欧美中文字幕在线观看| 久久综合九色综合久99| 欧美日本一道本在线视频| 国产精品视频成人| 在线看片成人| 亚洲影院在线| 麻豆精品传媒视频| 日韩午夜电影| 久久久免费精品| 国产精品久久久久久久久久直播| 激情综合自拍| 久久精品国产精品亚洲综合| 国产精品一区在线播放| 国产一区二区在线免费观看| 亚洲欧洲精品一区二区| 亚洲综合999| 免费成人高清| 中日韩美女免费视频网址在线观看| 欧美在线视频不卡| 欧美日韩八区| 在线观看亚洲精品视频| 亚洲一区3d动漫同人无遮挡| 久久影视精品| 午夜国产精品影院在线观看| 欧美精品久久一区| 在线精品高清中文字幕| 欧美一区二区三区四区高清| 亚洲国产福利在线| 亚洲自拍偷拍网址| 欧美日韩国产成人在线| 在线欧美日韩| 久久尤物视频| 午夜欧美精品久久久久久久| 欧美日韩三区四区| 亚洲精品黄色| 欧美大色视频| 久久gogo国模裸体人体| 国产精品美女久久久久久2018| 亚洲人成网站在线观看播放| 六月婷婷一区| 欧美一级片一区| 国产亚洲一级高清| 欧美一区二区久久久| 夜夜精品视频| 欧美午夜电影完整版| 一本一道久久综合狠狠老精东影业| 欧美大片在线观看| 快播亚洲色图| 亚洲日本一区二区| 亚洲国产婷婷香蕉久久久久久99 | 久久精品国产精品亚洲| 99成人在线| 欧美日韩亚洲一区三区| 99re66热这里只有精品3直播| 欧美黄色aa电影| 欧美69视频| 亚洲乱码精品一二三四区日韩在线 | 另类天堂av| 久久五月婷婷丁香社区| 麻豆国产精品777777在线 | 麻豆精品精华液| 老色鬼精品视频在线观看播放| 亚洲欧洲一区| 久久精品国产一区二区三| 国产日本欧美一区二区| 久久久久国产精品午夜一区| 午夜精品成人在线视频| 亚洲国产精品综合| 欧美日韩一区不卡| 欧美激情精品久久久| 久久乐国产精品| 日韩视频一区| 亚洲欧美日本国产专区一区| 欧美色图麻豆| 久久资源在线| 欧美日本精品一区二区三区| 99亚洲伊人久久精品影院红桃| 欧美ab在线视频| 亚洲人成77777在线观看网| 久久国产精品99国产| 国产在线乱码一区二区三区| 久久精品国产清高在天天线 | 国产综合亚洲精品一区二| 亚洲国产精品www| 一区二区激情| 国产在线欧美日韩| 中文久久精品| 亚洲图片你懂的| 国产精品久久久久久久免费软件 | 国产精品美女久久久久久2018| 久久免费高清视频| 国产一区二区三区在线观看网站 | 久久夜色精品国产亚洲aⅴ| 国内精品久久久久影院色| 欧美顶级艳妇交换群宴| 尤物九九久久国产精品的特点 | 亚洲欧美中文日韩v在线观看| 亚洲欧洲av一区二区三区久久| 亚洲精品视频免费在线观看| 午夜欧美不卡精品aaaaa| 精久久久久久| 久久综合久久久| 欧美国产日韩一区| 国产精品美女久久久久久免费| 欧美不卡三区| 一区二区在线视频| 亚洲欧美在线一区二区| 一区二区激情| 欧美va天堂va视频va在线| 亚洲免费视频在线观看| 亚洲视频综合| 国产综合久久久久久| 欧美精品一区二区蜜臀亚洲| 亚洲网站在线| 亚洲高清视频在线| 亚洲私人影院| 亚洲一区二区三区成人在线视频精品 | **网站欧美大片在线观看| 国内精品久久久久久影视8| 黄色资源网久久资源365| 最新亚洲激情| 欧美永久精品| 亚洲一区精品视频| aa级大片欧美三级| 亚洲欧美日韩一区在线| 夜夜嗨av一区二区三区中文字幕| 欧美中文在线视频| 欧美一区二区三区久久精品茉莉花| 国产伦精品一区二区三区免费迷| 久久综合久久综合久久| 欧美国产精品劲爆| 在线成人黄色| 欧美激情第1页| 玖玖精品视频| 亚洲综合大片69999| 国产日韩av一区二区| 欧美午夜免费影院| 久久成人免费网| 欧美一级视频精品观看| 欧美一级艳片视频免费观看| 国产精品黄视频| 亚洲午夜在线| 久久久噜噜噜久噜久久| 国产自产精品| 久久久另类综合| 亚洲国产精品va在线看黑人动漫 | 久久久免费精品| 欧美成人国产| 9久草视频在线视频精品| 欧美体内she精视频| 午夜精品视频在线| 欧美国产国产综合| 亚洲夜间福利| 韩国av一区二区| 欧美激情亚洲自拍| 亚洲女人天堂av| 欧美高清视频一区| 亚洲一区二区动漫| 狠狠色狠狠色综合日日五| 欧美精品乱人伦久久久久久| 亚洲天堂黄色| 欧美激情一区二区三区全黄| 亚洲在线观看免费| 尹人成人综合网| 国产精品成人播放| 久久亚洲国产精品日日av夜夜| 亚洲精品一品区二品区三品区| 欧美一区成人| av成人老司机| 国内精品久久久久伊人av| 欧美激情亚洲精品| 久久国产精品99久久久久久老狼| 亚洲巨乳在线| 欧美电影在线观看| 久久久久久九九九九| 亚洲一区二区三区中文字幕在线| 一区免费在线| 国产美女诱惑一区二区| 国产日韩欧美自拍| 国产在线高清精品| 亚洲第一级黄色片| 国产美女精品视频免费观看| 一区二区欧美视频| 欧美成人精品| 久久久精品一区| 性做久久久久久久免费看| 99热精品在线观看| 亚洲国产综合视频在线观看| 韩国三级电影久久久久久|