scoped_array

#define _SCL_SECURE_NO_WARNINGS
#include <iostream>  
#include <algorithm>  
#include <vector>
#include <boost/smart_ptr.hpp>  
using namespace boost;
using namespace std;



int main()
{
	int *arr = new int[100];//a dynamically allocated array   
	scoped_array<int> sa(arr); // scoped_array object proxied original allocated array 代理原始动态数组   

	fill_n(&sa[0], 100, 5);//use stdandard library algorithm,fill the entire array with 5  
	sa[30] = sa[10] + sa[20];//support operator[]  
	cout << sa[30] << endl;
	//desturctor,automatically destory resource  
	return 0;
}
/*
10
请按任意键继续. . .
*/

你可能感兴趣的:(scoped_array)