Talk About Network

Google





Programming > C - C++ Learning > Re: A question ...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 9 of 11 Topic 4120 of 4400
Post > Topic >>

Re: A question about structures

by Pat <pkelecy@[EMAIL PROTECTED] > Apr 19, 2008 at 07:38 PM

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. :^)
 




 11 Posts in Topic:
A question about structures
Pat <pkelecy@[EMAIL PR  2008-04-19 11:06:19 
Re: A question about structures
Francis Glassborow <fr  2008-04-19 16:20:42 
Re: A question about structures
Pat <pkelecy@[EMAIL PR  2008-04-19 17:13:44 
Re: A question about structures
Jensen Somers <jensen.  2008-04-19 23:25:38 
Re: A question about structures
Pat <pkelecy@[EMAIL PR  2008-04-19 19:38:17 
Re: A question about structures
Barry Schwarz <schwarz  2008-04-19 10:55:40 
Re: A question about structures
Pat <pkelecy@[EMAIL PR  2008-04-19 17:30:48 
Re: A question about structures
Richard Heathfield <rj  2008-04-19 22:10:45 
Re: A question about structures
Pat <pkelecy@[EMAIL PR  2008-04-19 19:38:01 
Re: A question about structures
Jensen Somers <jensen.  2008-04-20 13:35:43 
Re: A question about structures
Pat <pkelecy@[EMAIL PR  2008-04-20 11:09:30 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
localhost-V2008-12-19 Wed Jan 7 14:04:57 PST 2009.