#include // for std::unique_ptr #include // for EXIT_SUCCESS using namespace std; class obj { public: obj() { p = (const char*) malloc(20); } ~obj() { delete p;} private: const char* p; }; int main(int argc, char **argv) { // x is a unique_ptr storing an array of 5 ints unique_ptr x(new int[5]); obj *y = new obj[5]; x[0] = 1; x[2] = 2; delete y; return EXIT_SUCCESS; }