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

我輩豈是蓬蒿人!

C++ && keyWordSpotting

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

常用鏈接

留言簿(9)

我參與的團隊

搜索

  •  

積分與排名

  • 積分 - 7375
  • 排名 - 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 閱讀(534) 評論(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视频日韩| 亚洲福利一区| 欧美成人性生活| 一本色道久久综合一区 | 国产一区在线免费观看| 欧美一区二区久久久| 欧美一区二区视频免费观看| 国产欧美日韩一区二区三区在线| 久久av红桃一区二区小说| 欧美一区二区三区视频在线| 狠狠色丁香婷婷综合影院| 欧美 日韩 国产精品免费观看| 欧美成人情趣视频| 亚洲欧美不卡| 久久久久久久久一区二区| 亚洲毛片视频| 午夜精品影院| 亚洲欧洲在线看| 亚洲午夜精品| 在线精品视频在线观看高清| 亚洲国产一区二区a毛片| 欧美日韩精品中文字幕| 久久精品国产免费| 欧美理论在线播放| 久久xxxx精品视频| 欧美精品一卡二卡| 久久久久国产精品一区二区| 欧美激情1区| 久久美女性网| 欧美日韩午夜在线| 久久综合色婷婷| 欧美三级在线播放| 欧美福利视频在线观看| 国产精品人成在线观看免费| 欧美成人午夜免费视在线看片 | 欧美影院午夜播放| 99精品热视频| 玖玖玖国产精品| 性欧美1819性猛交| 欧美精品一卡| 欧美激情片在线观看| 国内精品久久久久久| 日韩视频一区| 亚洲精品午夜精品| 久久一二三国产| 欧美在线视频导航| 国产精品qvod| 亚洲精品一二三区| 亚洲精品乱码久久久久久久久| 香蕉精品999视频一区二区| 99在线精品视频| 欧美www视频在线观看| 久久激情综合网| 国产精品嫩草久久久久| 99re这里只有精品6| 亚洲激情专区| 久久乐国产精品| 久久一区二区三区四区| 国产欧美日韩综合| 午夜激情一区| 欧美一区二区福利在线| 国产精品久久久久一区| 在线午夜精品自拍| 亚洲一区免费视频| 欧美午夜视频在线观看| 亚洲免费观看高清完整版在线观看| 亚洲日本一区二区| 欧美成人免费网站| 亚洲国产日韩在线| 99热在这里有精品免费| 欧美国产欧美亚洲国产日韩mv天天看完整 | 久久9热精品视频| 久久av资源网站| 国产婷婷色一区二区三区四区| 亚洲一区黄色| 久久成人免费电影| 国产欧美日韩三区| 久久国产免费看| 麻豆成人综合网| 亚洲国内欧美| 欧美巨乳在线观看| 亚洲手机在线| 久久精品人人做人人综合| 国产一区二三区| 另类尿喷潮videofree| 亚洲第一毛片| 亚洲视频久久| 国产亚洲福利社区一区| 久久免费视频在线观看| 亚洲国产mv| 亚洲自拍偷拍麻豆| 国产拍揄自揄精品视频麻豆| 久久精品主播| 亚洲精品一区二区在线观看| 亚洲伊人色欲综合网| 国产一区久久久| 欧美精品在欧美一区二区少妇| 亚洲视频免费在线| 美女网站在线免费欧美精品| 日韩网站免费观看| 国产欧美一区二区三区在线老狼 | 欧美~级网站不卡| 日韩一级在线观看| 久久免费黄色| 亚洲午夜在线视频| 亚洲成色www8888| 国产精品高清免费在线观看| 久久久久99精品国产片| 一区二区三区成人| 免费美女久久99| 性色一区二区三区| 亚洲日韩视频| 激情文学一区| 国产精品久久久久77777| 久久久人成影片一区二区三区观看 | 一区二区视频免费在线观看| 欧美日韩无遮挡| 久久久久久久久久久成人| 在线亚洲伦理| 亚洲三级色网| 免费观看久久久4p| 久久国产色av| 亚洲欧美国产三级| 99精品欧美一区二区三区综合在线 | 欧美激情综合在线| 欧美在线视频一区二区| 一区二区三区日韩在线观看| 亚洲大片一区二区三区| 美女脱光内衣内裤视频久久影院| 欧美一区二区啪啪| 亚洲一区二区三区在线播放| 亚洲经典视频在线观看| 国模大胆一区二区三区| 国产区欧美区日韩区| 国产精品久久久久9999| 欧美日韩在线视频一区二区| 欧美高清视频免费观看| 老司机免费视频久久| 久久久精品2019中文字幕神马| 欧美一区二区观看视频| 亚洲欧美日韩在线高清直播| 一区二区三区四区五区视频| 日韩视频亚洲视频| 99日韩精品| 亚洲一区二区三区四区视频| 一区二区三区www| 亚洲天堂偷拍| 亚洲一区影院| 久久国产一区| 久热精品在线| 欧美精品在线网站| 欧美日韩精品免费| 国产精品xxxxx| 国产乱肥老妇国产一区二| 国产精品一国产精品k频道56| 国产精品人成在线观看免费| 国产日本欧洲亚洲| 好吊成人免视频| 亚洲国产一区二区三区a毛片| 亚洲国产精品久久91精品| 亚洲人成人77777线观看| 99视频在线观看一区三区| 一区二区三区国产在线| 午夜精品短视频| 久久久久久久一区二区三区| 欧美fxxxxxx另类| 亚洲肉体裸体xxxx137| 亚洲图片欧美一区| 久久蜜桃av一区精品变态类天堂| 欧美大成色www永久网站婷| 欧美视频二区| 国产自产2019最新不卡| 亚洲精品乱码| 亚洲欧美激情精品一区二区| 久久香蕉国产线看观看av| 亚洲国产一成人久久精品| 国产精品99久久不卡二区| 久久国产福利| 欧美日韩国产综合视频在线观看中文| 国产精品午夜av在线| 在线观看中文字幕不卡| 亚洲在线一区| 欧美sm重口味系列视频在线观看| 亚洲久久一区| 久久国产成人| 欧美性做爰猛烈叫床潮| 在线播放日韩专区| 亚洲综合激情| 亚洲大黄网站| 久久精品日韩| 国产精品黄色在线观看| 亚洲国产精品va在线看黑人| 亚洲免费影视| 最近中文字幕日韩精品| 欧美一区二区成人6969| 欧美性猛片xxxx免费看久爱| 亚洲激情不卡| 美女黄色成人网|