practices - Not using parentheses in constructor call with new(c++)
modern c++ practices (1)
Do the parentheses after the type name make a difference with new?
So I had in my main:
Class* pC = new Class;
It was working as
Class* pC = new Class();
I realized just today that I had omitted the parentheses (so I was hit by the "opposite" of the most vexing parse in a way).
My question: Are these two forms equivalent ?
If the class has a default constructor defined, then both are equivalent; the object will be created by calling that constructor.
If the class only has an implicit default constructor, then there is a difference. The first will leave any members of POD type uninitialised; the second will value-initialise them (i.e. set them to zero).