Aggregate Initialization Safety in C++
问题 Suppose I have the following struct: struct sampleData { int x; int y; }; And when used, I want to initialize variables of sampleData type to a known state. sampleData sample = { 1, 2 } Later, I decide that I need additional data stored in my sampleData struct, as follows: struct sampleData { int x; int y; int z; }; It is my understanding that the two field initialization left over from my pre- z data structure is still a valid statement, and will be compiled., populating the missing fields