日韩无码专区无码一级三级片|91人人爱网站中日韩无码电影|厨房大战丰满熟妇|AV高清无码在线免费观看|另类AV日韩少妇熟女|中文日本大黄一级黄色片|色情在线视频免费|亚洲成人特黄a片|黄片wwwav色图欧美|欧亚乱色一区二区三区

RELATEED CONSULTING
相關咨詢
選擇下列產品馬上在線溝通
服務時間:8:30-17:00
你可能遇到了下面的問題
關閉右側工具欄

新聞中心

這里有您想知道的互聯網營銷解決方案
C++標準擴展應用技巧分享

對于經驗豐富的編程人員來說,C++編程語言他們應該再熟悉不過了。這樣一款功能強大的語言,給他們的程序開發(fā)帶來了非常大的好處,我們今天就可以從C++標準擴展的方法來體驗一下這語言的功能特點。

今天實驗一下C++標準擴展中的shared_ptr的使用,結果在gcc4.1上怎么也編譯不過去,上網查了一下,還下載了TR1的手冊。終于明白了,要在#include中加入

 
 
 
  1. #include < tr1/memory> 
  2. #include < iostream> 
  3. #include < string> 
  4. #include < tr1/array> 
  5. #include < tr1/memory> 
  6. using namespace std;  
  7. using std::tr1::shared_ptr;  
  8.  
  9. class Widget  
  10. {  
  11. public:  
  12. Widget()   
  13. {  
  14. pstr = new string("Hello world!");  
  15. cout < <  "Widget's construction is called" < <  endl;   
  16. }  
  17. Widget(const Widget& rhs) { cout < <  "Widget's copy 
    construction is called" < <  endl; }  
  18. Widget& operator=(const Widget& rhs) { return *this; }  
  19. ~Widget()   
  20. {  
  21. delete pstr;  
  22. cout < <  "Destruction is called" < <  endl;   
  23. }  
  24. private:  
  25. string* pstr;  
  26. };  
  27. int main()  
  28. {  
  29. auto_ptr< Widget> pInv(new Widget);  
  30. auto_ptr< Widget> pInv2(pInv);  
  31. shared_ptr< Widget> pInvN(new Widget);  
  32. array< int, 5> a = {{1,2,3,4,5}};  
  33. cout < <  a[3] < <  endl;  
  34. return 0;  

這個文件。呵呵,可能是自己太不小心了!這次C++標準擴展的部分,根據TR1的說明主要有:

 
 
 
  1. Reference Wrappers   
  2. Shared_ptr   
  3. result_of   
  4. mem_fn   
  5. Function Object Binders   
  6. Polymorphic Function Wrappers   
  7. Type Traits   
  8. Random Numbers   
  9. Tuples   
  10. Array   
  11. Hash Functions   
  12. Regular Expressions   
  13. Complex Number Algorithms 

這些C++標準擴展部分,我們看到了期待以久的正則表達式也在這里面哦!


網站欄目:C++標準擴展應用技巧分享
URL分享:http://m.5511xx.com/article/dhjpgis.html