Validity int * array = new int [size] ();

int * array = new int [size]();

The operator () allows you to set all array values ​​to 0 (all bits are 0). it was called initialization of value.

With which version of g ++ is it valid?

What about other compilers?

Where can I find it in the standard?

+5
source share
3 answers

This is part of the C ++ standard; if it is not valid in g ++ then g ++ was inappropriate. There are several sections from the C ++ standard (ISO / IEC 14882: 2003):

5.3.4 / 15 regarding the new expression says:

If the new-initializer has the form (), the element is initialized with the value

8.5 / 5 regarding initializers says:

To initialize an object of type type T means:

- T - ( 9) (12.1), T ( , T );

- T - , , T ;

- T - , ;

-

, ints, , .

+6

() ( ) ++, ++ 98. , .

GCC, , () 2.x.x. , MSV++ () VC6. MSV++ () ++ 98.

+1

" , ++ " 2009-11-09:

8.5
...
7 - T :

  • T (, cv-) ( 9) (12.1), T ( , T );
  • T (, cv-) non-union , , Ts , .
  • T - , ;
  • .

...

0
source

All Articles