boost smart_ptr 3-> scoped_array

scoped_array P82

scoped_array 類似scoped_ptr,封裝了new[]操作符,爲動態數組提供了一個代理

  scoped_array<int> sa(new int[100]);

  sa[0] = 10;
  *(sa+1) = 20;

除非對性能有非常苛刻的要求,或者編譯器不支持標準庫,否則不建議使用scoped_array.

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章