For struct
s and class
es that have a constructor it's the same, the only difference between using the empty parentheses is for primitive types, which are zero-initialized if the parentheses are there, while they are left uninitialized otherwise.
Actually, it's more complicated than that; if you omit the parentheses:
- non-POD
class
es and struct
s are default-initialized, which actually means that their constructor is called;
- PODs (and in particular primitive types) are left not initialized;
If, instead, you specify the parentheses, the default-initialization is always performed, which, for primitive types, means zero-initialization.
The full story is explained at §5.3.4 ¶15; the default initialization is covered at §8.5.
Relevant standard quotation:
A new-expression that creates an
object of type T initializes that
object as follows:
- If the new-initializer is omitted:
- If
T
is a (possibly cv-qualified) non-POD class type (or
array thereof), the object is
default-initialized (8.5) If T
is a
const
-qualified type, the underlying
class type shall have a user-declared
default constructor.
- Otherwise, the object created has indeterminate value. If
T
is a
const
-qualified type, or a (possibly
cv-qualified) POD class type (or array
thereof) containing (directly or
indirectly) a member of
const-qualified type, the program is
ill-formed;
- If the new-initializer is of the form
()
, default-initialization
shall be performed (8.5);
- If the new-initializer is of the form (expression-list) and
T
is a
class type, the appropriate
constructor is called, using
expression-list as the arguments
(8.5);
- If the new-initializer is of the form (expression-list) and T is an
arithmetic, enumeration, pointer, or
pointer-to-member type and
expression-list comprises exactly one
expression, then the object is
initialized to the (possibly
converted) value of the expression
(8.5); — Otherwise the new-expression
is ill-formed.
(§5.3.4 ¶15)