J
jb.simon
Recently I was pinged in a code review about my use of the
initialization method
AStruct myStruct = { 0 } ;
Which initializes all elements of the myStruct to 0.
I was questioned on it because no one had seen this construct.
So i looked it up as best i could in the pointers to the Specification
that I find here and could not find any specific reference to this
construct. What i did find was reference to (paraphrasing) any values
not specified in the initializer are initialized to zero.
so it seems that the construct ={0}, sets the fisrst element to 0 and
since there are no more initializers present, all other structure
members are set to zero by default. Is this correct ?
Thanks
Joe
initialization method
AStruct myStruct = { 0 } ;
Which initializes all elements of the myStruct to 0.
I was questioned on it because no one had seen this construct.
So i looked it up as best i could in the pointers to the Specification
that I find here and could not find any specific reference to this
construct. What i did find was reference to (paraphrasing) any values
not specified in the initializer are initialized to zero.
so it seems that the construct ={0}, sets the fisrst element to 0 and
since there are no more initializers present, all other structure
members are set to zero by default. Is this correct ?
Thanks
Joe