Richard Heathfield wrote:
> Pat said:
>
> <snip>
>
>> But to clarify a comment you made, if I have a structure, say:
>>
>> struct coordinateDefinition
>> {
>> float x;
>> float y;
>> float z;
>> }
>>
>> and use that to define the structure,
>>
>> coordinateDefinition point1={1.5,2.3};
>>
>> then by default, point1.z=0?
>
> This is certainly true in C, because IF you initialise AT LEAST ONE of
the
> members of an aggregate object (e.g. a struct or an array), any that you
> don't initialise take on their default static initialisation values (0
for
> integer types, NULL for pointers, 0.0 for doubles, and recursively for
> aggregates). Whether it's true in C++, I'm not certain.
>
>> So you don't have to explicitly define all
>> the members?
>
> You don't have to explicitly *initialise* all the members, no.
>
>> What if z were a char type instead?
>
> <shrug> It would gain the value '\0' (i.e. a null character).
>
Thanks. This newsgroup is a great resource. :^)


|