S S posted:
Even if you do not put brackets () and write
int *p = new int[3];
then also it does the default initialisation for all 3 members of
array, any significance of brackets?
The Standard provides no such guarantee (well I'm 99% that it doesn't) --
if you want each element to be default-initialised, you'll have to use the
empty parentheses.
Testing it will do you no good, as I know of at least one implementation
that default-initialises new'ed memory regardless of whether you provide
the empty parentheses.
Anyhow, even if the empty parentheses were redundant, I would still put
them in, just as how I write:
int main()
{
static MyPOD arr[5] = {};
}
instead of:
int main()
{
static MyPOD arr[5];
}
Indeed, the chain brackets are redundant because static data always gets
default initialised... but nonetheless, they express clear intent.