Open Source Your Knowledge, Become a Contributor

Technology knowledge has to be shared and made accessible for free. Join the movement.

Create Content

Smart Pointers - Part III

#include <iostream>
#include <memory>
using namespace std;
int main() {
int n = 10;
// smart pointer to an array of int variables
unique_ptr<int[]> array(new int[n]);
for (int i=0; i<n; ++i) {
array[i] = i;
for (int i=0; i<n; ++i) {
cout << array[i] << ' ';
cout << endl;
return 0;
Open Source Your Knowledge: become a Contributor and help others learn. Create New Content