J
There is the following quotation line from standard C+++, which explains how the elements of the mass are initiated when the mass is initialized.int frequency[frequencySize] = { 0 };
The first thing to draw attention is that the masses belong to Aggregate type♪ We therefore refer to the section where the initialization of the aggregate types 8.5.1 Aggregates is described:7 If there are fewer initializer-clauses in the list than there are
members in the aggregate, then each member not explicitly initialized
shall be initialized from its brace-or-equal-initializer or, if there
is no brace-or-equalinitializer, from an empty initializer list(8.5.4).This extract from the standard indicates that if the initials are less than the elements in the body, the elements of the mass that do not have a clear initiator shall be initiated as if the empty figure brackets for each element indicated. I mean, you can imagine as follows:int frequency[frequencySize] = { 0, {}, {}, {}, {}, {}, {}, {}, {}, {}, {} };
We turn now to the standard for clarification, which means when there are empty figures. Section 8.5.4 List-initialization, paragraph 3, is written- Otherwise, if the initializer list has no elements, the object is
value-initializedWhich means value-initialized? This is described in section 8.5 Initializers of the standard8 To value-initialize an object of type T means: - otherwise, the object is zero-initialized♪And finally, the notion zero-initialized means (8.5 Initializers) 6 To zero-initialize an object or reference of type T means: - if T is a scalar type (3.9), the object is initialized to the value obtained
by converting the integer literal 0 (zero) to T;So all the elements of the mass that were not clearly inspired by the initiators are initiated by zero. That's why the record ended upint frequency[frequencySize] = { 0 };
equivalent to the following:int frequency[frequencySize] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
And eventually, they get the tape.int frequency[frequencySize] = { 0 };
equivalentint frequency[frequencySize] = {};
Note that in C, the last two entries are not equivalent. For language C, recordint frequency[frequencySize] = {};
I'm wrong, and the compiler will give a misstatement.