Diff between node *one=new node(); and node *one = new node;

struct node
{
bool is_b;
node* next;
};

What's the difference between
node *one=new node(); node *one = new node;

-->new node() zero initializes the data,is_b will be false, and all of the pointers will be NULL.
-->new node doesn't

For allocating arrays? there anything equivalent ?

int* arry_i = new int[10]; ->allocates uninitialized ints

int* arry_i = new int[10]();->allocates ints initialized to 0 on (recent) compilers
allocates ints initialized to 0 on all compilers
std::vector arry(10);

No comments :

Post a Comment