[prog] C++

Jimen Ching jching at flex.com
Fri Jan 23 15:27:42 EST 2004


On Tue, 20 Jan 2004, Kathryn Hogg wrote:
>wolf said:
>
>> 	int seat [10] = {NULL};
>
>This does not initialize all ten elements of the array and will only set
>the first element to NULL.

This sounded strange, so I looked it up.  For C, this statement is true
for automatic variables (which is the case for this example).  But for
external or static variables, the missing initializers will 'zero' the
array elements.

In C++, the standard says the missing initializers will use the default
constructor.  In this case, it's int(), which will set the array elements
to zero.

--jc
-- 
Jimen Ching (WH6BRR)      jching at flex.com     wh6brr at uhm.ampr.org


More information about the Programming mailing list