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

我輩豈是蓬蒿人!

C++ && keyWordSpotting

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

常用鏈接

留言簿(9)

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

搜索

  •  

積分與排名

  • 積分 - 7375
  • 排名 - 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

讓我們回過(guò)頭去看看這樣一個(gè)基本問(wèn)題:為什么有必要寫(xiě)自己的 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 閱讀(534) 評(píng)論(0)  編輯 收藏 引用 所屬分類(lèi): 讀書(shū)筆記
青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <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>
            亚洲人被黑人高潮完整版| 久久综合色播五月| 亚洲国内精品| 午夜在线电影亚洲一区| 日韩视频一区| 老色鬼久久亚洲一区二区| 久久se精品一区二区| 欧美亚洲成人免费| 亚洲国产一区二区三区青草影视| 国产欧美视频一区二区三区| 一区二区三区精品视频| 日韩图片一区| 欧美大片第1页| 欧美大片在线看免费观看| 国产一区二区三区免费在线观看| 亚洲视频导航| 一本色道久久综合亚洲精品高清 | 久久综合久久88| 久久免费少妇高潮久久精品99| 国产精品久久久免费| 一本色道久久88精品综合| 亚洲精品久久久久中文字幕欢迎你| 性做久久久久久久免费看| 午夜精品999| 国产精品久久久久久超碰| 日韩视频在线一区二区三区| 亚洲人午夜精品| 欧美国产亚洲视频| 91久久香蕉国产日韩欧美9色| 99精品99| 99热这里只有精品8| 欧美精品在线观看| 亚洲精品综合在线| 一区二区三区四区国产| 欧美午夜理伦三级在线观看| 一区二区欧美激情| 亚洲欧美影音先锋| 国产一区二区日韩精品| 欧美在线free| 欧美电影免费观看高清| 亚洲蜜桃精久久久久久久| 欧美日韩亚洲成人| 亚洲伊人网站| 美国十次了思思久久精品导航| 在线观看视频亚洲| 欧美a级理论片| 亚洲免费观看高清在线观看 | 狂野欧美激情性xxxx| 亚洲第一区中文99精品| 欧美国产日韩在线观看| 99在线|亚洲一区二区| 久久国产天堂福利天堂| 影音欧美亚洲| 欧美日韩另类丝袜其他| 午夜精品久久久久久久蜜桃app| 久久久天天操| 亚洲最新在线| 国产日韩欧美综合在线| 免费成人小视频| 一本一本久久a久久精品综合妖精 一本一本久久a久久精品综合麻豆 | 亚洲第一综合天堂另类专| 一本色道久久加勒比精品| 国产精品视频自拍| 美女主播一区| 亚洲午夜电影| 欧美激情视频在线播放| 亚洲欧美视频一区二区三区| 在线观看中文字幕亚洲| 国产精品扒开腿做爽爽爽视频| 欧美一区免费视频| 亚洲免费成人| 欧美岛国激情| 午夜免费在线观看精品视频| 亚洲国产成人av| 国产精品嫩草影院av蜜臀| 麻豆av一区二区三区| 亚洲一区久久久| 亚洲日本va在线观看| 久久久久88色偷偷免费| 亚洲主播在线| 亚洲精品日本| 黑人巨大精品欧美一区二区小视频| 欧美日本亚洲视频| 久久影视三级福利片| 欧美一区2区视频在线观看| 亚洲精品日韩精品| 欧美福利视频一区| 久久久www成人免费毛片麻豆 | 亚洲国产成人在线视频| 国产精品青草久久久久福利99| 猛干欧美女孩| 久久久www成人免费毛片麻豆| 亚洲图片欧洲图片日韩av| 亚洲国产三级在线| 美国十次成人| 久久一区二区精品| 久久久亚洲国产天美传媒修理工| 宅男噜噜噜66一区二区| 亚洲全黄一级网站| 亚洲国产精品第一区二区| 激情91久久| 国产自产精品| 国产一区二区按摩在线观看| 国产精品久久久久久模特| 欧美日韩免费高清| 欧美日韩午夜精品| 欧美日韩一区二区三区在线视频| 欧美黄色一区| 欧美黄色日本| 欧美连裤袜在线视频| 欧美精品午夜| 欧美日韩精品一区二区| 欧美精品一区二区三区蜜桃| 欧美国产视频日韩| 欧美另类视频| 欧美日韩在线精品| 国产精品精品视频| 国产精品视频精品视频| 国产欧美精品xxxx另类| 国产三区二区一区久久 | 国产欧美精品一区| 国产小视频国产精品| 狠狠久久亚洲欧美专区| 精品成人一区二区| 91久久视频| 亚洲调教视频在线观看| 亚洲视频www| 欧美在线视频全部完| 久久一区精品| 亚洲国产精品va在线观看黑人| 亚洲人成亚洲人成在线观看图片| 99re视频这里只有精品| 亚洲欧美电影院| 久久精品日产第一区二区| 欧美成人精品一区| 国产精品盗摄久久久| 国产综合色产| 亚洲精品免费一二三区| 午夜国产精品视频免费体验区| 久久九九99| 亚洲国产精品激情在线观看| 夜夜精品视频一区二区| 翔田千里一区二区| 欧美成年人视频| 国产精品久久九九| 雨宫琴音一区二区在线| 一区二区免费在线观看| 久久国产精品久久久久久久久久 | 蜜桃久久精品乱码一区二区| 91久久极品少妇xxxxⅹ软件| 亚洲一区二区精品视频| 老牛嫩草一区二区三区日本| 欧美日韩国产另类不卡| 国内精品美女av在线播放| 一区二区久久久久| 久久亚洲综合网| 在线一区二区日韩| 欧美不卡三区| 国产亚洲精品资源在线26u| 日韩亚洲欧美在线观看| 久久综合五月天婷婷伊人| 一本大道久久a久久精品综合| 久久嫩草精品久久久精品| 欧美体内谢she精2性欧美| 黑人一区二区三区四区五区| 亚洲系列中文字幕| 欧美黄在线观看| 欧美亚洲在线播放| 国产精品毛片| 亚洲深夜福利网站| 亚洲国产中文字幕在线观看| 久久国产一区二区三区| 国产精品乱看| 亚洲视频在线看| 亚洲欧洲精品一区二区三区| 久久精品女人的天堂av| 国产精品免费区二区三区观看| 99在线精品视频| 亚洲国产mv| 免费日韩成人| 亚洲国产精品专区久久| 久久在线免费| 久久精品99| 激情久久影院| 久热精品视频在线观看一区| 先锋影音国产精品| 国产精品一区免费观看| 午夜欧美精品| 亚洲性感美女99在线| 国产精品久久久久久久久久久久| 99国产精品99久久久久久| 欧美国产高潮xxxx1819| 麻豆精品精品国产自在97香蕉| 伊大人香蕉综合8在线视| 久久香蕉精品| 久久久久网站| 亚洲国产高清高潮精品美女| 亚洲大黄网站| 欧美激情中文不卡| 亚洲视频axxx|