It depends on what you mean by "difference in memory allocation".
Firstly, new
and new[]
are two independent memory allocation mechanisms, which can (and will) allocate memory with different internal layout, e.g. with different implementation-dependent household information associated with allocated memory block. It is important to remember that the first allocation has to be paired with delete
and the second - with delete []
. Also, for this reason, in a typical implementation the second allocation might consume more memory than the first.
Secondly, the initializer syntax ()
you used in the first allocation triggers value-initialization of the allocated object. Meanwhile, in your second allocation you supplied no initializer at all. Depending on the specifics of struct_type
class, this can lead to significant differences in initialization. For example, if struct_type
is defined as struct struct_type { int x; }
, the first allocation is guaranteed to set mystruct->x
to zero, while the second one will leave a garbage value in mystruct->x
. You have to do new struct_type[1]()
to eliminate this (probably unintended) difference.