What is the proper way to create an unique_ptr that holds an array that is allocated on the free store? Visual studio 2013 supports this by default, but when I use gcc versi
class Object {
private :
static int count;
public :
Object() {
cout << "Object Initialized " << endl;
count++;
}
~Object() {
cout << "Object destroyed " << endl;
}
int print()
{
cout << "Printing" << endl;
return count;
}
};
int Object::count = 0;
int main(int argc,char** argv)
{
// This will create a pointer of Object
unique_ptr
Objective of the post is that there are hidden small subtle things you need to understand. Creating array of objects is same as object array of unique_ptr. It will make difference only when you pass it in the argument. Creating array of object pointers of unique_ptr is also not very useful. So only below two you need to use in most scenarios.