#include <boost/scoped_array.hpp>

多个元素使用#include <boost/scoped_array.hpp>

单个元素使用#include <boost/scoped_ptr.hpp>

作用域数组

作用域数组的使用方式与作用域指针相似。关键不同在于,作用域数组的析构函数使用delete[]操作符来来释放所包含的对象。因为该操作符只能用于数组对象,所以作用域数组必须通过动态分配的数组来初始化。对应的作用域数组类名为boost::scoped_array,它的定义在boost/scoped_array.hpp里。

//error C2248: “boost::scoped_array<int>::scoped_array”: 无法访问 private 成员(在“boost::scoped_array<int>”类中声明)

1 #include <iostream>
2 #include <boost/scoped_array.hpp>
3 
4 void main()
5 {
6     boost::scoped_array<int>p(new int[10]);
7 
8     boost::scoped_array<int>pA(p);//error C2248: “boost::scoped_array<int>::scoped_array”: 无法访问 private 成员(在“boost::scoped_array<int>”类中声明)
9 }
原文地址:https://www.cnblogs.com/denggelin/p/5768572.html